hey guys.. i was wondering what the best way to go about getting a node from an xml doc into a javascript variable would be? i dont really want to use jquery because i believe that 开发者_运维问答i wont have too.. so far i have:
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","sc2cash.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
but now how i select the nodes? thanks
You can parse the returned XML using DOM manipulators. We'll need more information about the XML returned to be more specific.
xmlDoc=xmlhttp.responseXML;
// For example - get "person" tags if there were any
var people = xmlDoc.getElementsByTagName("person");
// All child nodes under the first person
var children = people[0].childNodes;
精彩评论