Parse XML using JavaScript - Stack Overflow you can parse the XML with Javascript DOM like this: if ...

Please Visit: http://ift.tt/1ajReyV



Parse XML using JavaScript - Stack Overflow

you can parse the XML with Javascript DOM like this:

if (window.DOMParser)

{

parser=new DOMParser();

xmlDoc=parser.parseFromString(txt,"text/xml");

}

else // Internet Explorer

{

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

xmlDoc.async=false;

xmlDoc.loadXML(txt);

}

And get specific values from the nodes like this:

//Gets house address number

xmlDoc.getElementsByTagName("streetNumber")[0].childNodes[0].nodeValue;

//Gets Street name

xmlDoc.getElementsByTagName("street")[0].childNodes[0].nodeValue;

//Gets Postal Code

xmlDoc.getElementsByTagName("postalcode")[0].childNodes[0].nodeValue;

http://ift.tt/1o8y744

http://ift.tt/1gIiu3H



Parse XML using JavaScript - Stack Overflow







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1gIiu3J

via LifeLong Community

No comments:

Post a Comment