You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "HERRICK, CHUCK (SBCSI)" <CH...@momail.sbc.com> on 2000/03/16 18:47:23 UTC

Enumerating across a NodeList

What's the recommended way to iterate across
an enumeration of Nodes in a NodeList?
 
Do you simply fire up a Java for loop and use
int j ;
NodeList.item(j) ; // ??
 
Or, do you use org.w3c.dom.traversal.TreeWalker?
 
org.w3c.dom.traversal.DocumentTraversal.createNodeIterator and
org.w3c.dom.traversal.NodeIterator?
 
Create a java.util.Enumeration of Nodes and use standard Java
while(enum.hasMoreElements()) { // ??
 
What does "best practices" say?
 

Re: Enumerating across a NodeList

Posted by Rajiv Mordani <Ra...@eng.sun.com>.
Depends on what the parser supports. If the parser you are using has dom
level 2 support you could use that else you could use the std java
Enumeration.

- Rajiv

--
:wq!

On Thu, 16 Mar 2000, HERRICK, CHUCK (SBCSI) wrote:

> What's the recommended way to iterate across
> an enumeration of Nodes in a NodeList?
>  
> Do you simply fire up a Java for loop and use
> int j ;
> NodeList.item(j) ; // ??
>  
> Or, do you use org.w3c.dom.traversal.TreeWalker?
>  
> org.w3c.dom.traversal.DocumentTraversal.createNodeIterator and
> org.w3c.dom.traversal.NodeIterator?
>  
> Create a java.util.Enumeration of Nodes and use standard Java
> while(enum.hasMoreElements()) { // ??
>  
> What does "best practices" say?
>  
>