![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I'm reading an XML file and populating an <OL> in the HTML file using the XML data. I grab the number of <DATA> elements in the flat XML tree and then remove any existing <LI>s from the previous run and populate the <OL> with new elements that I create. However it fails on the line where stories.appendChild(newLi) in the 2nd for loop. It gives an error of "Invalid argument". I don't understand why it is doing this, cos' if I comment that line out it compiles fine, and newLi does appendChild fine there... I tried checking no of kids of newLi and it says 1 which is correct. However stories just won't appendChild... please enlighten... :-( var x = xmlDoc.getElementsByTagName('DATA'); var stories = parent.pg_right.document.getElementById("stories") ; var kids = stories.childNodes.length; for (var i = kids-1 ; i >= 0 ; i-- ) { var li = stories.childNodes[i]; stories.removeChild(li); } for ( var k=0 ; k<x.length ; k++ ) { var newLi = document.createElement("li"); var txtLi = document.createTextNode(" "); newLi.appendChild(txtLi); stories.appendChild(newLi); } Thanks, Jules |
![]() |
| Thread Tools | |
| Display Modes | |
| |