This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes XML Parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML Parsing" Watch "XML Parsing" New topic

XML Parsing

Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
Hi Friends

It’s about xml parsing. I need to handle an xml document like this.

For retrieving <type> value I am using a method as below.

As this is a frequently using code in application, I would like to know if there any better way to do the same.

Thanks in advance…
Claudiu Chelemen
Ranch Hand

Joined: Mar 25, 2011
Posts: 71

Lately I find it nauseous to do the xml parsing manually, so I referred to an automated data binding solution, Castor, but I'm sure there are similar solutions around (jaxb?).

The advantage is that once you get to map the xml to a java bean, it renders your job very easy to marshall/unmarshall objects.
Afterwards, to get the needed value, you only have to call the respective getter on the bean.

Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
Hi Claudiu Chelemen,

But I am not allowed to use any data binding tools like Castor. Need to handle it manually.
Thanks for your quick reply...
Rob Spoor

Joined: Oct 27, 2005
Posts: 19656

Check out XPath.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: XML Parsing
Similar Threads
Updating Xml Element values
help with web service to display xml file contents using netbeans
Connection refused: connect in faces-config.xml
Read xml file placed on localhost
parsing the XML tags values having the same name