<html>
<body>
<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","depots.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("depots");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("Depot")[0].childNodes[0].nodeValue);
document.write("</td><td>");
'document.write(x[i].getElementsByTagName("Depot")[0].childNodes[0].nodeValue);
'document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
<?xml version="1.0"?>
<depots>
<depot="Aberdeen">
<address="some address"/>
</depot>
</depots>
<?xml version="1.0"?>
<depots>
<depot attr1="Aberdeen">
<address attr2="some address"/>
</depot>
</depots>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create table from XML</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$.get("depots.xml", function(data) {
$("body").append("<table border='1'></table>");
$.each($("depot", data), function() {
$("table").append("<tr><td>" + $(this).attr("attr1") + "</td></tr>");
});
});
});
</script>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create table from XML</title>
<body>
<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","depots.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("depots");
for (i=0;i<x.length;i++)
{
for(j=0;j<x[0].childNodes.length;j++) {
if(x[0].childNodes[j].nodeType == 1) {
document.write("<tr><td>");
document.write(x[0].childNodes[j].getAttribute("attr1"));
document.write("</td>");
}
}
}
document.write("</table>");
</script>
</body>
</html>