• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iterate through string get elements

 
dale con
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all can someone please tell me how i convert a string to xml, so that i can iterate through it and grab the elements and their values

e.g. if my string is this
String xml = "<person><firstname>first</firstname><lastname>first</lastname></person>";

i want to iterate through to get the firstname and lastname elements and then get their vlaues

thanks for any help
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use XML parsers.

Look at the javax.xml.parsers package.
 
Naveen Vooka
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at various XML parsers available
http://www.devx.com/xml/Article/16921
http://xml.apache.org/xerces-j/
http://www.xml.com/pub/rg/Java_Parsers

--------------
Naveen Vooka
www.devsquare.com
DevSquare - Online Application Development
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic