File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Getting all child element from root element 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 "Getting all child element from root element" Watch "Getting all child element from root element" New topic
Author

Getting all child element from root element

Tay Thotheolh
Ranch Hand

Joined: Aug 07, 2008
Posts: 84


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

Joined: Jan 01, 2009
Posts: 874


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

Joined: Aug 07, 2008
Posts: 84
Thanks for the help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting all child element from root element