• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Parsing

 
Jomy George
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out XPath.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic