wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML Parsing" Watch "XML Parsing" New topic
Author

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.

Cheers
Claudiu
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
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Check out XPath.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: XML Parsing
 
Similar Threads
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
Updating Xml Element values