The example in this article describes the way JavaScript loads an XML file. Share to everyone for your reference, specific as follows:
XML file Var uRl that needs to be read = "Jsreadxml.xml";
var xmldoc; Initialize to assign the above defined variable/function showcurcity () {if window.
ActiveXObject) {xmldoc=new ActiveXObject ("Microsoft.XMLDOM"); xmldoc.async= "false" Xmldoc.load (uRl); GetValue ();} else if (document.implementation && document.implementation.createDocument) {xmldoc=
Document.implementation.createDocument ("", "root", null);
Xmldoc.load (URL);
Xmldoc.onload=getvalueff; }/else {//return null;//}//} function GetValue () {var nodes=xmldoc.documentelement.childnodes; var now=new Date (
); for (i=0;i<nodes.length;i++) {var value=nodes.item (i). Childnodes.item (0). Text; alert (Nodes.item (i).
Childnodes.item (1). text);
Alert (Nodes.item (i). Childnodes.item (2). text); The function Getvalueff () {var ccode=xmldoc.getelementsbytagname ("date"); var now = new Date (); var Nowvalue=now.getfullye
AR () + ' year ' + (Now.getmonth () +1) + ' month ' +now.getdate () + ' Day '; for (i=0;i<ccode.length;i++) {alert (Xmldoc.getelementsbytagname ("imgsrc") [I].childnodes[0].nodevalue); Alert (Xmldoc.getelementsbytagname ("title") [I].childnodes[0].nodevalue);
Alert (xmldoc.getelementsbytagname ("url") [I].childnodes[0].nodevalue);
}
}
I hope this article will help you with your JavaScript programming.