Mon Aug 06, 2007 10:56 am
<html>
<script type="text/javascript">
//read data from xml file
function getXMLdata()
{
var request=null;
//Depends on the your browser
if(window.XMLHttpRequest)
{
//Mozila FireFox
request=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
//Internet Explore
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(request)
{
//The autocalled funtion when the status changed
request.onreadystatechange = function() {
//Status cases of the readState varrible
if(request.readyState==0)
document.getElementById('status').innerHTML='Uninitialized';
else if(request.readyState==1)
document.getElementById('status').innerHTML='Loading...';
else if(request.readyState==2)
document.getElementById('status').innerHTML='Loaded';
else if(request.readyState==3)
document.getElementById('status').innerHTML='Interactive';
else if(request.readyState==4)
{
document.getElementById('status').innerHTML='Completed';
var xml_response = request.responseXML;
xml_response.loadXML(request.responseText);
var myname=xml_response.getElementsByTagName('name');
document.getElementById('Txtdata').value=myname[0].childNodes[0].nodeValue;
}
}
request.open("GET","Data.xml");
//send the request
request.send(null);
}
else
//not request opened
document.getElementById('Txtdata').value='Nothing';
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- used for as a meta informaton to the browser -->
<title>Untitled Document</title>
</head>
<span id = "status"></span ><br>
<input type="text" id="Txtdata" />
<input type="button" value="Load" onclick="getXMLdata();" />
<body>
</body>
</html>
<?xml version = "1.0" ?>
<Boss>
<name>AAA</name>
<age>43
</age>
<sex>Male
</sex>
<name>ALI</name>
<age>43
</age>
<sex>Male
</sex>
</Boss>
document.getElementById('Txtdata').value=myname[0].childNodes[0].nodeValue;
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.