SoFunction
Updated on 2025-03-10

JS Read XML File Sample Code


//Read XML file
function loadXML(xmlFile) {
var xmlDoc;
if () {
xmlDoc = new ActiveXObject("");
= false;
(xmlFile);
}
else if ( && ) {
xmlDoc = ("", "", null);
= false;
(xmlFile);
} else {
alert('Your browser does not support this system script!');
}
return xmlDoc;
}

//Output XML file
function outXML(filename){
var xmlDoc = loadXML(filename);
var x = ("properties");
var text=x[0].(/</g,"&lt;");
return text;
}

function dirXML(xmlDoc){
var entry=("properties")[0].getElementsByTagName("entry");
for (var i=0,j=; i<j;i++){
(entry[i].getAttribute("key"));
(entry[i].childNodes[0].nodeValue);
}
}