Copy codeThe Code is as follows:
// Read the XML file
Function loadXML (xmlFile ){
Var xmlDoc;
If (window. ActiveXObject ){
XmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
XmlDoc. async = false;
XmlDoc. load (xmlFile );
}
Else if (document. implementation & document. implementation. createDocument ){
XmlDoc = document. implementation. createDocument ("", "", null );
XmlDoc. async = false;
XmlDoc. load (xmlFile );
} Else {
Alert ('your browser does not support this system script! ');
}
Return xmlDoc;
}
// Output the XML file
Function outXML (filename ){
Var xmlDoc = loadXML (filename );
Var x = xmlDoc. getElementsByTagName ("properties ");
Var text = x [0]. outerHTML. replace (/</g, "<");
Return text;
}
Function dirXML (xmlDoc ){
Var entry = xmlDoc. getElementsByTagName ("properties") [0]. getElementsByTagName ("entry ");
For (var I = 0, j = entry. length; I <j; I ++ ){
Console. log (entry [I]. getAttribute ("key "));
Console. log (entry [I]. childNodes [0]. nodeValue );
}
}