2011-06-26 127 views
1

確定...問題解析使用jQuery(IE9)XML

,所以我得到這個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 ... :(我希望它不是瀏覽器:(

+0

* OOPS - 注意上面我做了一個錯誤標籤在JavaScript代碼中的作者應該閱讀Artists。非常感謝和歉意.... – Alhasan

回答

1

你需要的標籤包裝到另一個容器中。你不能選擇文檔的根。

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

JsFiddle