I'm using Safari for windows. It tells me that document.prototype.loadXML is undefined. What are my other options to create XML document?
A:
From http://www.w3schools.com/Xml/xml_parser.asp (reformatted a bit):
The following code loads and parses an XML string:
function loadXML(text) { var xmlDocument = null; // Internet Explorer try { xmlDocument = new ActiveXObject("Microsoft.XMLDOM"); xmlDocument.async = false; xmlDocument.loadXML(text); } // Standards-compliant method. catch (exception) { parser = new DOMParser(); xmlDocument = parser.parseFromString(txt, "text/xml"); } return xmlDocument; }
Note: Internet Explorer uses the
loadXML()
method to parse an XML string, while other browsers use theDOMParser
object.
John Kugelman
2009-07-10 03:09:57