I am new to JavaScript vs. XML so the following might be newbie questions.
I have a simple XML file that I want to be read into a web page and parsed out into a table. The xml file looks like:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE deathsheet [
	<!ELEMENT deathsheet	(person+)>
	<!ELEMENT person	(weapons+)>
	<!ELEMENT weapons	(weapon+)>
	<!ELEMENT weapon	(#PCDATA)>

	<!ATTLIST person name CDATA #REQUIRED>
	<!ATTLIST person MUS CDATA #REQUIRED>
	<!ATTLIST person CUF CDATA #REQUIRED>
]>
<deathsheet>
	<person MUS="9" CUF="9" name="Zom0">
		<weapons>
			<weapon>M9</weapon>
			<weapon>M16</weapon>
			<weapon>M203</weapon>
		</weapons>
	</person>
	<person MUS="5" CUF="20" name="Zom1">
		<weapons>
			<weapon>M9</weapon>
		</weapons>
	</person>
	<person MUS="7" CUF="20" name="Zom2">
		<weapons>
			<weapon>Pipe</weapon>
		</weapons>
	</person>
	<person MUS="8" CUF="20" name="Zom3">
	</person>
</deathsheet>
I am able to load this file via a function using the following:
Code:
<script type="text/javascript">
	function loadXMLString(xmlName) {
		if (window.XMLHttpRequest) {
			xhttp=new XMLHttpRequest();
		} else {
			// Internet Explorer 5/6
			xhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xhttp.open("GET", xmlName, false);
		xhttp.send("");
		return xhttp.responseXML;
	}
</script>
..
..
..
deathsheetObj = loadXMLString("deathsheet.xml");
Initially, I simply want to loop through the file, extract the data, and display it in a table (it will get more complex later, but I need to take baby-steps).

What I want to do is loop through the object extracting each person, and within each person, extract the weapons. I have gotten the person part to work, but am missing some core concept for extracting the weapons. I see many examples on-line of how to grab specific elements and attributes, but my code needs to be dynamic. The xml file will change on a regular basis, and the extraction needs to somehow determine this. My code for parsing of the data is as follows:
Code:
noPersonNodes=deathsheetObj.documentElement.getElementsByTagName("person").length;
document.write("noPersonNodes "+noPersonNodes+"<br>");
for (xx1=0; xx1 < noPersonNodes; xx1++) {
	x=deathsheetObj.getElementsByTagName("person")[xx1].attributes;

	document.write("<tr>");
	document.write("<td>"+xx1+"</td>");
	document.write("<td>"+x.getNamedItem("name").nodeValue+"</td>");
	document.write("<td>"+x.getNamedItem("MUS").nodeValue+"</td>");
	document.write("<td>"+x.getNamedItem("CUF").nodeValue+"</td>");

	txt = "";
	txt = deathsheetObj.childNodes[1].hasChildNodes();
	document.write("<td>"+txt+"</td>");

	var1 = deathsheetObj.getElementsByTagName("person")[xx1];
	var2 = var1.childNodes[1];

	if (var2.nodeName == "weapons") {
	    var3 = var2.childNodes[1];
	    alert(xx1+" (child node) "+var2.nodeName);
	}
	document.write("</tr>");
}
I would also appreciate any constructive criticism. Like I said, I am new to this, so parts of this might be working, but not written the way they should be. If you have better names for the variables, that would also be good. I don't totally understand which pieces are objects and which are not.
Thanks in advance.