aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parsing Nested XML Nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing Nested XML Nodes" Watch "Parsing Nested XML Nodes" New topic
Author

Parsing Nested XML Nodes

Chris Baty
Ranch Hand

Joined: Nov 23, 2008
Posts: 30
Hi guys,
I'm trying to parse a simple (to me) XML document with nested nodes that looks like this:


So I wrote a method to parse this file and it works except the number of <followers> is always 5 and the count is always 1.



Any ideas would be appreciated.

Thanks.
Chris>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I can't really read that code. Could you break it up into manageable chunks first?
Chris Baty
Ranch Hand

Joined: Nov 23, 2008
Posts: 30
Okay, I figured it out, with help from Eclipse. Problem #1: <followers> are a sibling, not a child. Problem #2: I was confusing nodelist items with element items. Here's the answer:



Hope this helps someone else
Chris>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

<meta>Do you find this readable? I mean, I wasn't just saying that for *my* benefit, but yours too. Code like this takes too much time to re-understand.</meta>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing Nested XML Nodes