this is my current file:
and is based on an XML file in this format:
The question i have is how to get it to do this for each "Company" element in my XML file. So that i basically have a table with
etc...
do i have to have the table made from within the script part of the html file?
its basically got to stand up to me adding a new "Company" element in the .xml and then that gets outputted too.
note that it has to be in javaScript as thats what part of the coursework is on.
thanks in advance!!
Code:
<html>
<head>
<script type="text/javascript">
function loadXML() {
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("pizza.xml");
nodes=xmlDoc.documentElement.childNodes;
l1left.innerText = nodes(0).attributes(0).text;
l1right.innerText = nodes(0).childNodes.length;
}
</script>
<title>PizzaList</title>
</head>
<body onload="loadXML()" bgcolor=#a0a000>
<h1>Pizza Companies in Portsmouth</h1>
<table width="800px" bgcolor=#a0a0a0 border="2px">
<tr>
<td><b>Company Name</b></td> <td><b>Number of Branches</b></td>
</tr>
<tr>
<td><span id="l1left"></span></td>
<td><span id="l1right"></span></td>
</tr>
</body>
</html>
and is based on an XML file in this format:
Code:
<pizzaList>
<company name="Company 1">
<branch>
.....
</branch>
</company>
<company name="Company 2">
<branch>
.....
</branch>
<branch>
.....
</branch>
</company>
</pizzaList>
The question i have is how to get it to do this for each "Company" element in my XML file. So that i basically have a table with
Code:
Company Name Number of Branches
Company 1 3
Company 2 6
Company 3 1
do i have to have the table made from within the script part of the html file?
its basically got to stand up to me adding a new "Company" element in the .xml and then that gets outputted too.
note that it has to be in javaScript as thats what part of the coursework is on.
thanks in advance!!