XML<?xml version="1.0" encoding="ISO-8859-1"?><root><item1>One</item1><item2>Two</item2><item3>Three</item3></root>
Javascript <script type="text/javascript">function loadFileToElement(filename){var parseXml; //var xmlDoc=document.implementation.createDocument("","",null); var xmlhttp = new XMLHttpRequest();xmlhttp.open("GET", filename, false);xmlhttp.setRequestHeader('Content-Type', 'text/xml');xmlhttp.send(); if(xmlhttp.readyState == 4 ) {parseXml=xmlhttp.responseXML.documentElement; for(var i=0; i<parseXml.childNodes.length;i++){document.getElementsByTagName("p")[0].innerHTML+="<p>"+parseXml.childNodes.length+" : "+i+" : "+parseXml.childNodes[i].tagName+" : "+parseXml.childNodes[i].textContent}//for }//if}//if </script>
Javascriptvar request = false; function readyRead() { if(request.readyState == 4) { if(request.status == 200) { try { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(request.responseText); } catch(e) { try { parser = new DOMParser(); xmlDoc = parser.parseFromString(request.responseText, "text/xml"); } catch(e) {alert(e.message)} } var cells = xmlDoc.getElementsByTagName("flooring"); for(var i = 0; i < cells.length; i++) {...} } }} try {request = new XMLHttpRequest();}catch(e) { try {request = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) { try {request = new ActiveXObject("Microsoft.XMLHTTP");} catch(failed) {request = false;} }}if(!request) alert("Ошибка инициализации XMLHttpRequest!"); request.open("GET", filename, true);request.onreadystatechange = readyRead();request.send();
Javascriptif(request.status == 0) {}
Javascriptif(request.status == 200) {}
XML<?xml version="1.0" encoding="windows-1251"?>
Javascriptxmlhttp.overrideMimeType('text/xml;charset=windows-1251');