File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing Nested XML Nodes

 
Chris Baty
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't really read that code. Could you break it up into manageable chunks first?
 
Chris Baty
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic