This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Iterating same level 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 "Iterating same level nodes" Watch "Iterating same level nodes" New topic
Author

Iterating same level nodes

John Best
Greenhorn

Joined: Oct 02, 2011
Posts: 9

Hi there,

<World>
<Country>Argentina</Country>
<Country>Bangladesh</Country>
<Country>China</Country>
<Country>Denmark</Country>
<Country>Iran</Country>
<Country>Iraq</Country>
</World>

how to iterate the above XML to get the Country's


Have a nice day
JB
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 13001
    
    5
You need to get familiar with the standard Java library for manipulating XML.

Given the "World" org.w3c.Dom.Eement, you can getElementsByTagName("Country") to get a NodeList which you can use to iterate.

Bill

 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Iterating same level nodes
 
It's not a secret anymore!