[jdom-interest] JDOM Parsing - Iterating Through Elements Named the Same

bob mcwhirter bob at werken.com
Mon Dec 10 13:14:44 PST 2001


Use XPath.

	/file/service[position()=last()]

-bob



On Mon, 10 Dec 2001, Hunter Hillegas wrote:

> I have an XML file like this:
> 
> <file>
>     <service id="0"><stuff></stuff></service>
>     <service id="1"><stuff></stuff></service>
>     ...
>     <service id="9"><stuff></stuff></service>
> </file>
> 
> There can be an arbitrary number of <service> elements, but I always want
> the last one.
> 
> Is there a way to iterate through elements that have the same name to get to
> the end?
> 
> What is the best way to do this?
> 
> Thanks,
> Hunter
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 




More information about the jdom-interest mailing list