【问题标题】:Problem parsing XML using Jquery (IE9)使用 Jquery (IE9) 解析 XML 的问题
【发布时间】:2011-06-26 17:59:38
【问题描述】:

好的……

所以我得到了这个 XML 文件,我需要解析它....

<Current> 
    <Artists>
         <![CDATA[ Artists of movie ]]>
     </Artists> 
     <Title>
         <![CDATA[ title of movie ]]>
     </Title> 
    <Image/>
    <Purchase/>
</Current>

...... // 以这种方式继续......

这是我的代码....

$(document).ready
(

function()
{ 

 $.get("url of xml file ",{}, 
    function(xml)
     {
         $("Current", xml).each
         (
            function(i)
                {
                    author= $(this).find("Authors").text();
                     alert(author);
                }
         );
    }
    );
});

为什么它不起作用?请注意,此代码在 IE9 中 ... :( 我希望它不是浏览器 :(

【问题讨论】:

  • * OOPS - 注意上面我犯了一个错误,Javascript 代码中的标签作者应该阅读艺术家。非常感谢和道歉....

标签: jquery xml parsing internet-explorer-9 using


【解决方案1】:

您需要将标签包装到另一个容器中。您不能选择文档的根目录。

<List>
    <Current> 
        <Artists>
            <![CDATA[ Artists of movie ]]>
        </Artists> 
        <Title>
           <![CDATA[ title of movie ]]>
        </Title> 
       <Image/>
       <Purchase/> 
   </Current>
</List>

JsFiddle

【讨论】:

    猜你喜欢
    • 2011-05-02
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多