This article illustrates the method of parsing XML file across browsers with JS implementation. Share to everyone for your reference, specific as follows:
The following code loads an XML document ("Note.xml") into the XML parser:
<script type= "Text/javascript" >
function Getxmlhttpobject () {
var xmlhttp=null;
try {
//Firefox, Opera 8.0+, Safari
xmlhttp=new XMLHttpRequest ();
} catch (e) {
//Internet explorer
try {
xmlhttp=new activexobject ("msxml2.xmlhttp");
} catch (e) {
xmlhttp=new ActiveXObject (" Microsoft.XMLHTTP ");
}
}
return xmlHttp;
}
function Loadxmldoc () {
var xmlhttp = Getxmlhttpobject ();
Xmlhttp.open ("Get", "Note.xml", false);
Xmlhttp.send ();
Xmldoc=xmlhttp.responsexml;
return xmldoc;
}
PS: About XML Format files, small series here to recommend a few online tools, I believe that you can use in the future programming development:
Online XML format/compression tools:
Http://tools.jb51.net/code/xmlformat
XML code online formatting landscaping tools:
Http://tools.jb51.net/code/xmlcodeformat
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
More about JavaScript content to view the site topics: "JavaScript operation XML File Tips Summary", "JavaScript Ajax Operating Skills Summary", "JavaScript in the JSON Operation tips Summary", " JavaScript switching effects and techniques summary, "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and Skills summary", "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", JavaScript traversal algorithm and techniques summary and JavaScript mathematical Operational Usage Summary
I hope this article will help you with JavaScript programming.