Thanks, this got me on the right path...one other question and I'll leave
everyone alone. It seems that my characters always have at least one,
usually two blank lines per element. For instance if I have
System.out.println ("Characters: " + s); The variable s is my character
string, I'll have lines in my output that basically show nothing but
Characters: and it's then blank.

I have the ignorable white space defined, but it doesn't seem to do anything
in this case. What I need to know is how I can avoid it printing these blank
lines.

Thanks everyone!

~Cheers
Brent

-----Original Message-----
From: Stevie Goh [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 27, 2002 9:26 PM
To: [EMAIL PROTECTED]
Subject: RE: Help!!


Here is what I do. You define one or more method in your Class that
implements ContentHandler interface. Then somewhere in your main class,
I am sure you will need to call your contenthandler in
setContentHandlerMethod. From there you can get hold reference to your
contenthandler class. Thus, you can get your result by calling
contenthandler.yourmethodhere(); Due to fundamental difference in the
SAX and DOM Processing, I think this is the best way you can do.

Hope this help.


-----Original Message-----
From: Brent Scott [mailto:[EMAIL PROTECTED]
Sent: Monday, January 28, 2002 9:58 AM
To: [EMAIL PROTECTED]
Subject: RE: Help!!

Stupid question I'm sure..however, what does ContentHandler return? I
have
my main class that starts the parsing, then a custom content handler
class
that implements ContentHandler. However, in my main class I'm not sure
what
I can use that's returned in ContentHandler. What I did in my
ContentHandler
was create a StringBuffer of data...I need that StringBuffer to
available in
the main class

Hope this makes sense and thanks in advance for the patience with the
newbie.

-Brent

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 19, 2002 6:53 PM
To: [EMAIL PROTECTED]
Subject: Re: Help!!


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




Reply via email to