Javascript XML 解析错误,未关闭的 CDATA 部分
我正在使用以下 javascript 行将 XML 字符串解析为 XML DOM 对象:
this._xmlParser = new DOMParser();
this._xmlDoc = this._xmlParser.parseFromString(txt,"text/xml");
我的 xml 字符串如下所示:
<?xml version="1.0"?>
<event>
<id>41717876</id>
<start>2011-08-16T10:16</start>
<end>2011-08-16T10:16</end>
<title>New Calendar Event</title>
<location>
<line>Your location goes here.</line>
</location>
<description>
<line>Your description goes here.</line>
</description>
<!-- %%spider:url%% -->
<further-info><![CDATA[ hello&goodbye ]]></further-info>
<tag>all</tag>
<url>www.google.com</url>
</event>
CDATA 部分似乎格式良好。为什么我会收到未关闭的 CDATA 部分的解析器错误?
I am using the following lines of javascript to parse an XML string into an XML DOM object:
this._xmlParser = new DOMParser();
this._xmlDoc = this._xmlParser.parseFromString(txt,"text/xml");
My xml string looks like this:
<?xml version="1.0"?>
<event>
<id>41717876</id>
<start>2011-08-16T10:16</start>
<end>2011-08-16T10:16</end>
<title>New Calendar Event</title>
<location>
<line>Your location goes here.</line>
</location>
<description>
<line>Your description goes here.</line>
</description>
<!-- %%spider:url%% -->
<further-info><![CDATA[ hello&goodbye ]]></further-info>
<tag>all</tag>
<url>www.google.com</url>
</event>
The CDATA section seems to be well-formed. Why am I receiving a parser error for an unclosed CDATA section?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很抱歉回答我自己的问题,但我发现问题的根源与浏览器响应限制 xml-rpc 调用中文本节点的大小有关。我在此处发现了以下有用的注释:
我收到的浏览器响应在不知不觉中将我的文本节点拆分为多个文本节点。请注意任何有类似问题的人。
Sorry to answer my own question, but I discovered that the source of my problem had to do with the browser response limiting the size of text nodes in xml-rpc calls. I found the following useful note here:
The response I was receiving to the browser had unknowingly split my text node into multiple text nodes. Heads up for anyone who has a similar issue.