我怎么能用AJAX和jQuery从这个XML中提取数据?

时间:2011-07-25 16:36:44

标签: jquery xml ajax

我特别想要拉出其中一个表示图像文件夹的节点。我指的节点是channelimagepath。提前谢谢。

这是XML文件:

<channel title="My Title">
    <shortname>aa_aaperil</shortname>
    <artist>Aesthetic Apparatus</artist>
    <channellogosmall>images/asp.jpg</channellogosmall>
    <channelimagepath>images/base/flash/aa_aaperil/</channelimagepath>
    <channeldesign>images/channel/aa_aaperil/aa_aaperil-design.gif</channeldesign>
    <totalimagesback>100</totalimagesback>
    <totalimagesmiddle>100</totalimagesmiddle>
    <totalimagesfront>100</totalimagesfront>
    <pagepath>/artistchannel.php/channel/aa_aaperil</pagepath>
    <description><![CDATA[Here's the description.]]></description>
    <allowblocking>true</allowblocking>
</channel>

2 个答案:

答案 0 :(得分:1)

folder=yourXMLHTTPObject.responseXML.documentElement.getElementsByTagName("channelimagepath");
theFolderYouWant=folder[0].firstChild.nodeValue;

你还需要ajax部分吗?

答案 1 :(得分:0)

的一些变体
var blah = '';
$(xml).find("channelimagepath").each(function(){
    blah = $(this).text();
  });