Monday, 15 July 2013

javascript - Link Xml file to HTML -


I have created a simple XML file and an HTML file that displays the XML file description but it does not work. The same folder is an all ...

My XML file is here:

student.xml

   

HTML file:

studentDetails.html

   

and javascript file:

loadXMLDoc.js

  function loadXMLDoc (student) {if (window.XMLHttpRequest) {xhttp = New XMLHttpRequest (); } And // code for IE5 and IE6 {xhttp = New ActiveXObject ("Microsoft.XMLHTTP"); } Xhttp.open ("GET", student, incorrect); Xhttp.send (); Return xhttp.responseXML; }  

plz help

I have written an example for you Working in Firefox, but not in Chrome. I think this is because you are requesting a XML file locally. It should be through a server

   ") for (i = 0; i & lt; x.length; i ++); Document.write (x [i] .getElementsByTagName ("name") [0] .childNodes [0] .nodeValue); Document.write ("& lt; / td> gt; & lt; td & gt;"); Document.write (x [i] .getElementsByTagName ("age") [0] .childNodes [0] .nodeValue); Document.write ("& lt; / td> "); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

students.xml

   & Lt; / Student & gt; & Lt; Students & gt; & Lt; Name & gt; Afghan & lt; / Name & gt; & Lt; Age & gt; 22 & lt; / Age & gt; & Lt; Exp & gt; Nothing & lt; / Exp> & Lt; / Student & gt; & Lt; / Students & gt;  

No comments:

Post a Comment