• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

reading the contents of an element using SAX parser

 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 28416
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul,

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