• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

reading the contents of an element using SAX parser

 
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
 
Marshal
Posts: 25949
69
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...
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic