Display XML Content in an HTML table
In this article, I will explain how to Display XML Content in an HTML table.It will demonstrate XML files, XML formatting and XML transformation.
JavaScript used together with XML(AJAX).
In the following example, we are going to parse an XML file ("test.xml"), and display the contents of each element as an HTML table row. Learn Display XML Content in an HTML table.
Find the code for Displaying XML Content in an HTML table
<html>
<body>
<script type="text/javascript">
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","test.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1' cellspacing=0,cellpadding=2>");
var x=xmlDoc.getElementsByTagName("Emp");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("AGE")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
Hi rajesh
Give the Details Procedure.Its through An error