You are already looping over all of the properties (which have IDs themselves..), which all contain reference, address and bullets.
There are a number of ways to do this, but XPath is probably the simplest to allow future extension:
Just do exactly the same for the bullets in a new loop:
Code
<script>
function loadXMLDoc() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xmlhttp.open("GET", "propertiescombined.xml", true);
xmlhttp.send();
}
function myFunction(xml) {
var i;
var xmlDoc = xml.responseXML;
var table="<thead ><tr><th >main property image</th><th>Title</th></tr></thead><tbody>";
var x = xmlDoc.getElementsByTagName("property");
for (i = 0; i <x.length; i++) {
// here we are looping over properties
table += "<tr><td>" + x.getElementsByTagName("street")[0].childNodes[0].nodeValue + </td><td>" + x.getElementsByTagName("name")[0].childNodes[0].nodeValue + </td></tr>";
// now find the bullets for the current property with XPath:
var path = "propertydatas/property[@id='" + x[i].getAttribute('id') +"']/bullets"
var bulletNodes = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ANY_TYPE, null);
var result = nodes.iterateNext();
while (result) {
// iterate over bullets for the property and do something with them..
stuff += result.childNodes[0].nodeValue + "<br>";
result = nodes.iterateNext();
}
}
document.getElementById("myTable").innerHTML = table;
}
window.onload = loadXMLDoc ();
</script>
hope that helps
This post was edited by Klexmoo on Jun 23 2020 02:58pm