Currently, I have a piece of code that reads an XML document and uses it to construct an HTML page, similar to markdown. In essence, the issue lies in the JavaScript line at the end with CAROUSEL, which is generating 7 carousel divs instead of just 1 as intended. I understand why it's producing 7 instances (to some extent), but I'm unsure how to modify it to only create one. The ITEM tags within the CAROUSEL tag in the XML section indicate which images should be included in each specific carousel.
JS:
var col9div = null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",'xml/index'+page_counter+".xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var col9div = document.createElement("div");
});
var tempvar = arr.length;
console.log(tempvar);
$(col9div).addClass("col-md-9");
$("#bannersize").append(col9div);
flush();
function flush(){
var activity_element_idcounter = 0;
var module_element_idcounter = 0;
var x=xmlDoc.getElementsByTagName("MODULE");
for (i=0;i<x.length;i++)
{
var getlastli = $(".sidecounter:last");
module_element_idcounter++;
col9div.insertAdjacentHTML('beforeend', '<div class="row"><div class="col-md-12 well"' + ' id="module' + module_element_idcounter + '"><div id="skrollr-div' + module_element_idcounter + '"></div></div>');
var scanner = x[i].getElementsByTagName("*");
for (var q=0;q<scanner.length;q++){
activity_element_idcounter ++;
$.each(scanner[q].childNodes, function(){
else if (scanner[q].nodeName === "CAROUSEL"){
do something here
}
XML:
<MODULE>
<CAROUSEL>
<ITEM>assets/images/index5/tehran-carousel/tehran-day-and-night.jpg</ITEM>
<ITEM>assets/images/index5/tehran-carousel/tehran-day-and-night-1.jpg</ITEM>
<ITEM>assets/images/index5/tehran-carousel/tehran-bazaar-entrance.jpg</ITEM>
</CAROUSEL>
</MODULE>
Kind regards, Robbie