a quick utility function to convert from string to xml object.
Reference:
http://www.w3schools.com/xml/xml_dom.asp
Useful properties/methods for XML Object:
Reference:
http://www.w3schools.com/xml/xml_dom.asp
function stringToXML(text)
{
var xmldoc;
if (window.DOMParser)
{
var parser=new DOMParser();
xmldoc=parser.parseFromString(text,"text/xml");
}
else // Internet Explorer
{
xmldoc=new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async=false;
xmldoc.loadXML(text);
}
return xmldoc;
}
Useful properties/methods for XML Object:
- getElementsByTagName(tagName)
- childNodes[index]
- nodeValue
- getAttribute(atttributeName)
- setAttribute(name, value)
- createElement(name)
- createTextNode(text)
- appendChild(element)
- removeChild(element)
No comments:
Post a Comment