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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.