aspose file tools*
The moose likes Beginning Java and the fly likes iterate through string get elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "iterate through string get elements" Watch "iterate through string get elements" New topic
Author

iterate through string get elements

dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
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

Joined: Sep 28, 2005
Posts: 225
You can use XML parsers.

Look at the javax.xml.parsers package.


Regards,<br />Seb<br /> <br />SCJP 1.4
Naveen Vooka
Greenhorn

Joined: Oct 13, 2004
Posts: 25
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iterate through string get elements