Forum Moderators: open

Message Too Old, No Replies

XML data is not read

         

phparion

8:36 pm on Jan 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi i have written a code in java script to read data from xml file, but its not reading any values from xml file and also not giving any error, please help me in this, i have done the following coding,

the html page has the following code

Code:
<html>
<head>
<script type="text/javascript">
var xmlDoc
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("profile.xml");
getmessage()
}

function getmessage() {
document.getElementById("rank").innerHTML=
xmlDoc.getElementsByTagName("rank")[0].firstChild.nodeValue
}
</script>

</head>
<body onLoad="loadXML()" bgcolor="#999900">
<p><b>Name:</b> <span id="rank"></span><br />

</body>

</html>

the XML file has the following code

Code:
<?xml version="1.0"?>
<profile>
<name>Haroon Ahmad</name>
<rank>Project Manager</rank>
<salary>5000</salary>
<office>ET Development Wing</office>
<job>Programmer and PHP Guru</job>
<phone>0300 5937133</phone>
</profile>

phparion

4:02 am on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i got it working, in fact i didnt use the main function loadXML closing brackets thats why it was not working.