Nodelist question 2003-08-12 - By Jeffery B. Rancier
I am somewhat confused by the following snippet:
,---- | 1 Node currentNode; | 2 Document doc = createDocument(); | 3 NodeList elementList = doc.getElementsByTagName( "element" ); | 4 | 5 if ( elementList.getLength() > 0 ) | 6 { | 7 System.out.println( "elementList.getLength():" + elementList.getLength( ) ); | 8 currentNode = elementList.item( 0 ); | 9 currentNodeIndex = 0; | 10 | 11 NodeList elemChildren = currentNode.getChildNodes(); | 12 System.out.println( "elemChildren:length:" + elemChildren.getLength() , | 13 } | 14 System.out.println( "currentNode:" + currentNode ); `----
The output is as follows:
,---- | elementList.getLength():5 | elemChildren:length:10 | currentNode:[element: null] `----
Why is currentNode null? It's nodeType says ELEMENT_NODE. Am I missing something fundamental here? The number of children do match up with my document, BTW. I probably should change the name 'element', though, to avoid confusion. -- Thanks, Jeff
,---- | Jeffery B. Rancier | | Softechnics | a METTLER TOLEDO company `----
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|