One strategy is to keep a stack of strings in your parser subclass. When an element is started, push an empty string on the stack. When characters() is called, append to the string. When the element ends, pop the stack.
john ________________________________________ From: Mirko Braun [[email protected]] Sent: Wednesday, November 11, 2009 1:13 PM To: [email protected] Subject: Re: SaxParser and tag without a value Hi Boris, thank you for your answer. I think you are right. This would explain why i get cryptical signs as a value for this tag. Is there any possibility to determine such tags as tags which has no value (with SaxParser and the BaseHandler)? Best regards, Mirko -------- Original-Nachricht -------- > Datum: Wed, 11 Nov 2009 19:36:38 +0200 > Von: Boris Kolpackov <[email protected]> > An: [email protected] > Betreff: Re: SaxParser and tag without a value > Hi Mirko, > > Mirko Braun <[email protected]> writes: > > > In my xml file there is a tag like <tag></tag>. > > If i use the characters() method of the BaseHandler > > for this tag, i would expect to get an empty string > > but i get an value with some cryptical characters. > > This element does not contain any data so I would expect > the parser not to call characters() at all. > > Boris > > -- > Boris Kolpackov, Code Synthesis > http://codesynthesis.com/~boris/blog > Open-source XML data binding for C++ > http://codesynthesis.com/products/xsd > XML data binding for embedded systems > http://codesynthesis.com/products/xsde > Command line interface to C++ compiler > http://codesynthesis.com/projects/cli
