I tried running the following code but i did not get the output and i am not able to figure out the error. please let me know whats wrong in this program. The code is:
xml code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="style.css"?>
<person_details>
<person>
<name>divya</name>
<ph_num>34567899</ph_num>
</person>
<person>
<name>chetan</name>
<ph_num>568994</ph_num>
</person>
</person_details>
html code:
<html>
<head>
<title>
hi
</title>
</head>
<body>
<script>
if(window.XMLHttpRequest){
xmldoc=new XMLHttpRequest();
}
else{
xmldoc=new ActiveXObject("Microsoft.XMLHTTP");
}
xmldoc.open("GET","person.xml",false);
xmldoc.send();
xmlDoc=xmldoc.responseXML;
var x=xmlDoc.getElementsByTagName("person");
document.getElementById("myName").innerHTML=x[0].getElementsByTagName("name")[0].childNodes[0].nodeValue;
</script>
<div id="myName"></div>
</body>
</html>
No comments:
Post a Comment