you need to write a class which extends DefaultHandler .. then over ride the
relevant methods to save your data to the hash table
so if your xml is like
<element1>
blah blah
</element1>
then you over ride the methods
characters(char[] ch, int start, int length)
and put the charecters that you are getting in a StringBuffer.
and override
endElement(java.lang.String uri, java.lang.String localName,
java.lang.String qName)
and put the data from the String buffer in the hashtable and create a new
StringBuffer... there is no way to clear the String buffer
and remember to make the string buffer an instance variable so that
it is accessible to both the methods
hope it helps
anshuman
Brent Scott wrote:
> Newbie to Java and probably in way over my head, but I need to finish this
> project or I'll go crazy :)
>
> I'm trying to create a SAX driven parser using Xerces. I chose SAX over DOM
> for minimal memory usage. What I'm not sure how to do is put the results in
> a Hashtable. It's important that I be able to do this so I can later call
> the results of the Hashtable.
>
> Is this something that is possible? I've seen one way it's done with DOM but
> the way DOM parses and the way SAX does seem seemingly different.
>
> If someone could help me or at least point me in the right direction I would
> be most appreciative. I am more than willing to send current code to willing
> participant.
>
> Thank you Group!!
>
> ~Cheers, Brent