Reputation: 184
how to parse this xml file pasted in the url
<?xml version="1.0" encoding="UTF-32"?>
<mp3gallery>
<albums selectAtStartItemNo = "1">
<album id="1">
<author><![CDATA[MORR]]></author>
<tracks>
<item id="1">
<title><![CDATA[x1]]></title>
<song>www.gooogle.com</song>
</item>
<item id="2">
<title><![CDATA[x2]]></title>
<song>www.yahoo.com</song>
</item>
</tracks>
</album>
</albums>
what i need to select value "www.gooogle.com" using only the id (attribute)
example : select(2 which is the id ) return www.yahoo.com
using javascript and hope not using jquery
thanks
Upvotes: 0
Views: 194
Reputation: 27687
Firefox and Webkit browsers use DOMParser
, while IE uses XMLDom
. I'd strongly recommend not reinventing the wheel and hacking together a cross-browser solution - just use jQuery.
Using jQuery, you write something like this:
xmlDoc = $.parseXML(xml);
$(xmlDoc).find("item[id='2']").attr("song");
Upvotes: 2