You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by liu lang <la...@hotmail.com> on 2001/11/15 11:21:59 UTC

A small question about startElement event?

Hello
I am chinese C++ programmer. This morning I was downloading XML4C from your 
site.
And I writed a simple processing XML file application at Solaris 2.6.
I writting my code bellowing:
===========================================
void Handler::startElement (const XMLCh *const uri,const XMLCh *const
                            localname,const XMLCh *const qname,
                             const Attributes &attrs)
{
    printf("--%s--\n", localname);
}
===========================================
But I only get following result on console.

%./Reader
----
----
----
----
%

My question is why I can't get String value and print them?
Thanks for your answer.
I am watching replying email.
Liamliu

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: A small question about startElement event?

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"liu lang" <la...@hotmail.com> writes:

> Hello
> I am chinese C++ programmer. This morning I was downloading XML4C from
> your site.
> 
> And I writed a simple processing XML file application at Solaris 2.6.
> I writting my code bellowing:
> ===========================================
> void Handler::startElement (const XMLCh *const uri,const XMLCh *const
>                             localname,const XMLCh *const qname,
>                              const Attributes &attrs)
> {
>     printf("--%s--\n", localname);
> }

localname is an XMLCh* encoded in UTF-16. Passing it to printf() as if
it was a char* is not what you want. You must transcode it into a
char* first:

  char* ln = XMLString::transcode(localname);
  printf("--%s--\n", ln);
  delete [] ln;

transcode() allocates memory that you are responsible for.

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: A small question about startElement event?

Posted by Juergen Hermann <jh...@web.de>.
On Thu, 15 Nov 2001 10:21:59, liu lang wrote:

>    printf("--%s--\n", localname);

localname is an XmlCh*, a unicode string. You cannot print that with 
sprintf. Look at XMLString::transcode.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: A small question about startElement event?

Posted by Evert Haasdijk <ev...@zukkespijkers.nl>.
Liamliu,

The thing is that localname is a XMLCh*, not a char*. You can use transcode
to convert between the two.

hth, evert

> -----Original Message-----
> From: liu lang [mailto:lang_liu@hotmail.com]
> Sent: Thursday, November 15, 2001 10:22 AM
> To: xerces-c-dev@xml.apache.org
> Subject: A small question about startElement event?
>
>
> Hello
> I am chinese C++ programmer. This morning I was downloading XML4C
> from your
> site.
> And I writed a simple processing XML file application at Solaris 2.6.
> I writting my code bellowing:
> ===========================================
> void Handler::startElement (const XMLCh *const uri,const XMLCh *const
>                             localname,const XMLCh *const qname,
>                              const Attributes &attrs)
> {
>     printf("--%s--\n", localname);
> }
> ===========================================
> But I only get following result on console.
>
> %./Reader
> ----
> ----
> ----
> ----
> %
>
> My question is why I can't get String value and print them?
> Thanks for your answer.
> I am watching replying email.
> Liamliu
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org