View Single Post
  #9 (permalink)  
Old 11-05-2008, 05:34 PM
LeadMagnet's Avatar
LeadMagnet LeadMagnet is offline
Mr. Tambourine Man
 
Join Date: Jun 2007
Location: Ireland
Gender: Male
Posts: 1,381
Default

I'm not really up on my xml, but i think your problem is here:
Code:
x[i].getElementsByTagName("oil")[0].childNodes[0].nodeValue);
you're repeating yourself there by typing x[i].getElementsByTagName("oil")[0]
You've already defined x as being xmlDoc.getElementsByTagName("oil") so that means you're writing:
xmlDoc.getElementsByTagName("oil").getElementsByTagName("oil")[0]. So that's going to fail straight off the bat.

It's not a huge deal for just getting things working, but for validation purposes, avoid using document.write

Take a look at the code here on this page and it should set you on the right path. You'll notice it uses document.createElement and document.createTextNode instead of document.write. That's the proper DOM way to do it.

JavaScript - Import XML Document
__________________
Subtlety is my middle name... and first and last in case you didn't get the point.
Reply With Quote