简体   繁体   中英

Problem parsing XML using Jquery (IE9)

ok ...

so I got this XML file and I need to parse it ....

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

...... // keeps on going in this manner ....

and here is my code ....

$(document).ready
(

function()
{ 

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

why is it not working? Please note that this code is in IE9 ... :( I hope its not the browser :(

you need to wrap the tag into another container. you can't select the root of the document.

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

JsFiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM