Hi,

Thanks a lot for the reply.

In your reply, in the sample scenario, you have shown characters() method
called many times. But, I think the scenario is like this:

startElement( "tag1", ...)
characters("\n", 1)
startElement( "tag2", ...)
characters("\n", 1)
characters( "someData", 8 )
endElement( "tag2" )
characters("\n", 1)
endElement( "tag1" )
characters("\n", 1)

At least this is what the output of my program suggest. I am using SAX2
parser.

Please let me know:
1. How to avaoid the characters() method to be called for data that I want
to ignore, such as "\n" corresponding to a newline after start of a tag and
a newline after end of a tag?
2. For all the characters within "<tag2>" and "</tag2>", is the characters
method called only once, or the parser may call it more than once?

Thanks once again,
-Vinay Kakade.

----- Original Message -----
From: "Tuan Hoang" <[EMAIL PROTECTED]>
To: "Vinay Kakade" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, December 20, 2001 10:32 AM
Subject: Re: How to get attribute name in characters() method?


> Using the SAX parser, you could get something similar to this:
>
> startElement( "tag1", ...)
> startElement( "tag2", ...)
> characters( "so", 2 )
> characters( "me", 2 )
> characters( "Dat", 3 )
> characters( "a", 1 )
> endElement( "tag2" )
> endElement( "tag1" )
>
> Basically in your handler for characters(), keep adding to a string
> object (I use a class data member).  When endElement() is called,
> do what you need to do with the element "name" and its value stored in
> the class string object.  Then make sure you erase the class string
> object before you return from the endElement() handler.
>
> Hope this helps.
> Tuan
>
>
> On Wed, 19 Dec 2001, Vinay Kakade wrote:
>
> > Hi,
> >
> > I have just started learning about Xerces C++ parser. I hope my question
is appropriate for this mailing list.
> >
> > My question is: In the characters() method of HandlerBase class, can we
get the name of the enclosing attribute in which in which this character
data appear?
> >
> > For example:
> >
> > <tag1>
> >     <tag2>someData</tag2>
> > </tag1>
> >
> > In this xml file, when characters() method is called when "someData" is
encountered, I want to retrieve name of enclosing attribute i.e. "tag2" in
this case.
> >
> > Please let me know if there is any pre-implemented method to do this. I
serached the documentation but could not find any.
> >
> > Thanks in Advance,
> > -Vinay Kakade.
> >
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to