Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating same level nodes

 
John Best
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic