This article describes the method of cross-browser parsing XML files implemented by JS. Share it for your reference, 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: Regarding the xml format file, the editor will recommend several online tools for you here. I believe you can use it in future programming and development:
Online XML formatting/compression tools:
http://tools.VeVB.COM/code/xmlformat
XML code online formatting and beautification tool:
http://tools.VeVB.COM/code/xmlcodeformat
Online XML/JSON mutual conversion tool:
http://tools.VeVB.COM/code/xmljson
For more information about JavaScript, please check this site's special topics: "Summary of JavaScript's XML File Operation Skills", "Summary of Ajax Operation Skills in JavaScript", "Summary of JSON Operation Skills in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques", and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.