开发者

Malformed XML, responseXML and jQuery - how to let then work?

I need to parse some web pages with jQuery, and I've tried to make use of methods related to the httpRequest.responseXML approach. In this way, I've found that XML for this page appears malformed (that is what jQuery.isXMLDoc(httpRequest.responseXML) s开发者_如何转开发ays), and so I don't have any way to work with it.

The strange aspect is that, if don't load the page in an httpRequest, but I parse with jQuery the same page opened in a tab in a Firefox extension, everything works successfully.

Can you suggest me a reason because there are such different behaviours, and how to make the first option work correctly?

Thanks, ciao!

Livio


Firefox may be 'correcting' the XML for you automatically (XML is fairly predictable, adding a missing closing tag for example).

When it's passed onto the extension, it already contains the corrections done by the browser itself and jQuery recognizes this as valid XML.

When you load the source directly, there's no interference and thus, the parsing fails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜