Jump to content

[SOLVED] JavaScript and the XML DOM


rhyspaterson

Recommended Posts

Have a strange issue here lads.

 


...

...

for(var x = 0; x < allPrinters.length; x++){ 

	importXML(allPrinters[x]);

	// -------------------------------------------------
	alert('foo');		
	// -------------------------------------------------

	var name = xmlDoc.getElementsByTagName("system.sysname.0")[0].childNodes[0].nodeValue;
	var type = xmlDoc.getElementsByTagName("25.3.2.1.3.1")[0].childNodes[0].nodeValue;
	var consoleDisplay = xmlDoc.getElementsByTagName("43.16.5.1.2.1.1")[0].childNodes[0].nodeValue;

	var row = document.createElement('TR');
	tmp.appendChild(row);

		var container = document.createElement('TD');
		container.innerHTML= x;
		row.appendChild(container);

		var container = document.createElement('TD');
		container.innerHTML=name;
		row.appendChild(container);

		var container = document.createElement('TD');
		container.innerHTML=type;
		row.appendChild(container);	

		var container = document.createElement('TD');
		container.innerHTML=consoleDisplay;
		row.appendChild(container);											

}		
document.getElementById('writeroot').appendChild(newTable);

...

 

The above code works, but only when i have the alert('foo'); in my code. Otherwise it just comes out blank (and with no errors - firebug says nothing, nor IE).

 

Seems to be an issue with writing to the DOM, but i have no idea what is going on.

 

The code is looping through ~80 xml files (don't ask me why :P) and loading them into the DOM each time. Then i just grab a few variables and write them to the page. It only works when i put the alert in there though (and have to press OK ~80 times haha).

 

Suggestions?

 

Cheers,

Rhys

Link to comment
https://forums.phpfreaks.com/topic/125426-solved-javascript-and-the-xml-dom/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.