English 中文(简体)
Chrome与IE和Firefox中的XML解析
原标题:XML parsing in Chrome vs IE and Firefox

我使用JQuery来解析从服务器返回的一些XML,并使用它来填充表;不幸的是,这只适用于Firefox和IE,而不适用于Chrome。以下相关代码:

var xmlDoc = $.parseXML(xml);
$(xmlDoc).find( z\:row ).each (
    function ()
    {//this stuff never gets executed in Chrome}

我也尝试过使用$(xmlDoc).find(“[nodeName=z:row]”),但这给了我一个无效的语法错误。我已经验证了传递给$.parseXML的xml确实是一个有效且完整的xml文档。

(我查找z:row的原因是这是SharePoint Web Services的输出。)

如有任何帮助,我们将不胜感激!:)

编辑:问题已解决。事实证明,在我查看的网站上发布nodeName语法的人发布了无效语法。它需要是[nodeName=“z:row”]才能是一个自包含的字符串,所有引号都是必需的。*摇头*

最佳回答

问题已解决。事实证明,在我查看的网站上发布nodeName语法的人发布了无效语法。它需要是[nodeName=“z:row”]才能是一个自包含的字符串,所有引号都是必需的。*摇头*

问题回答

我认为你的问题在于函数()后的换行符

JavaScript在行后隐式插入分号。在一些浏览器上,他们可以判断函数()不应该有换行符,但在ECMAScript标准中却没有。

执行函数()(向上移动

编辑:哦,如果问题解决了,那么忽略上面的内容。但是,遵循开发指南(如http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml