• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading the contents of an element using SAX parser

 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an XML that could be nested, eg



i want to get the value of a particular element, eg the value of element B is


and the value of element C is "C1".
Also, i want to use SAX parser and not the DOM parser.

I was wondering if there is a library which uses SAX parser to accomplish this, instead of me writing a SAX parser.

Thank you

Rahul
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to write a SAX parser. You just have to write a ContentHandler.

And no, there isn't a ContentHandler implementation available which searches for data in a C element which is the child of a B element which is the child of the root element which is an A. That's what you have to write. It isn't difficult, you just have to have your ContentHandler keep track of where it is in the document.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,

I wrote it up and it works...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic