Using JavaScript DOM Parser to create XML Document from XML strings.
var doc;//xml dom
// Mozilla and Netscape browsers
if (document.implementation.createDocument) {
var parser = new DOMParser()
doc = parser.parseFromString(xmlstr, "text/xml")
// Internet Explorer
} else if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM")
doc.async="false"
doc.loadXML(xmlstr)
}
//doc is dom strucure, using node traverse to access the nodes
// Mozilla and Netscape browsers
if (document.implementation.createDocument) {
var parser = new DOMParser()
doc = parser.parseFromString(xmlstr, "text/xml")
// Internet Explorer
} else if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM")
doc.async="false"
doc.loadXML(xmlstr)
}
//doc is dom strucure, using node traverse to access the nodes
XML DOM - The Element Object
沒有留言:
張貼留言