You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Renato Tegon Forti <re...@acm.org> on 2012/10/10 23:07:48 UTC
Question about sax and xml entity!
Hi All,
I have one doubt (or better, a problem!)
I heve one xml, like this:
// .
<xNome>A&S ELETRO</xNome>
//..
Then I run a sax parser. I have
class sax_handlers
: public HandlerBase
, private XMLFormatTarget
{
void characters(const XMLCh* const chars, const XMLSize_t length)
{
char* name_char = XMLString::transcode( chars );
std::string name = name_char;
XMLString::release(&name_char);
// .
}
My problem is that in 'name' I have only 'A'! The '&' not appears on my
variable!
My question is, where is my '&'?
Thanks
Re: Question about sax and xml entity!
Posted by Alberto Massari <Al...@progress.com>.
Hi Renato,
the character() callback can be invoked several times to build the
string found inside an element node; this can happen if the string
started at the end of the current buffer of text loaded from the file,
or (like in this case) because an entity reference has been found and
potentially this could require loading an included file. You will see
the ' character in the next call, followed by a third call to report "S
ELETRO".
It's the SAX handler's task to join these three calls into a single line
of text.
Hope this helps,
Alberto
Il 10/10/2012 23:07, Renato Tegon Forti ha scritto:
> Hi All,
>
> I have one doubt (or better, a problem!)
>
> I heve one xml, like this:
>
> // .
>
> <xNome>A&S ELETRO</xNome>
>
> //..
>
> Then I run a sax parser. I have
>
> class sax_handlers
>
> : public HandlerBase
>
> , private XMLFormatTarget
>
> {
>
> void characters(const XMLCh* const chars, const XMLSize_t length)
>
> {
>
> char* name_char = XMLString::transcode( chars );
>
> std::string name = name_char;
>
> XMLString::release(&name_char);
>
> // .
>
> }
>
> My problem is that in 'name' I have only 'A'! The '&' not appears on my
> variable!
>
> My question is, where is my '&'?
>
> Thanks
>
>
>
>