velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <bi...@progress.com>
Subject Re: Iterating through XML Elements - How?
Date Fri, 22 Mar 2002 03:18:32 GMT
Hello Terry,

Terry Steichen wrote:
> 
> From: "Geir Magnusson Jr." <geirm@optonline.net>
> > > Appreciate knowing what I'm missing here.  I kind of suspect it has
> something
> > > to do with the need to use an iterator, but not sure.
> >
> > That's the right idea.
> 
> OK - I give up.  What's the right idea?  How do I use iterators here?
> 
> > Question - why not use dom4j?  You can use Xpath, and it returns normal
> > java.util.Lists....
> 
> At the moment, the DOM document is generated by JTidy, because it 'cleans it
> up' before I work with it.
> 
> 
> So back go the original question:  How can I iterate through a NodeList with
> #foreach()?

Okay.  Then like Geir said, try dom4j.  It can convert DOM to dom4j's node
model.  See http://www.dom4j.org/cookbook/cookbook.html#NB2C for more
info.  Also, if jTidy can generate SAX events you could have dom4j read
those from jTidy.

Another option is to write a little class that implements Iterator and
given a DOM NodeList could traverse it.

-Bill

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message