I think you are being confused by the toString() implementation on an 
Element. 'currentNode' isn't null -- if it were the line would be 'currentNode: 
null'. It's a valid element. I don't have the source handy, but I beleive the 
null is the 'value' of the node (Element nodes usually, if not always, have 
null as a value in my experience).

Chris


-----Original Message-----
From: Jeffery B. Rancier [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 6:20 AM
To: [EMAIL PROTECTED]
Subject: Nodelist question


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to