Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting all child element from root element

 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi , that's my code above. How do I get all following elements from an XML document ?

I use the below codes to test...



My xml I am parsing is this below...



And the output when running the test is...


How could nodes length be 0 when there's so many nodes in the xml documents as you can see ?

If you noticed, I didn't put to class and full codes since it's going to make this post very long so I only post the imports and the essential codes so that anyone can get an idea what I am trying to do.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tay,



Why do you want to get NodeList here. getDocumentElement() returns Element(which implements Node) . Typically you get Node first and get child Nodes from it. This is right way to use.




 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic