Re: [xml] simple questions
- From: Stefan Seefeld <seefeld sympatico ca>
- To: Andre Street <rcrowther totalise co uk>
- Cc: xml gnome org
- Subject: Re: [xml] simple questions
- Date: Fri, 09 Sep 2005 13:51:49 -0400
Andre Street wrote:
...and now I'm stuck, because I havn't a clue how to cast the retrieved
into something usable as a basic data type on my system ie. a char*, or
a c++ 'string' (the data originates as a simple string, no control
characters, e.g. '48' or 'pizza').
My current, desperate solution is
//for a c++ string
temp << xmlNodeGetContent(node);
SomeVariable = temp.str();
Which works, but I suspect does something horrible with the wide characters
of UTF-8. Maybe even hazardous.
ASCII is a subset of UTF-8, so whenever you are sure the data really only
contain ASCII (such as '48' or 'pizza') you can treat a 'xmlChar *' as if it
were a 'char *'.
xmlChar *content = xmlNodeGetContent(node);
will do the trick (UTF-8 is NULL-terminated, too).
Anyway, if anyone could paste a code example of how to get xmlchar* back to
the native char* of the local system, many thanks (before I bail out and
about c++ i/o and interfaces with file handling...)
When you can't be sure about the content being ASCII I would indeed
suggest to use an external library to provide unicode datatypes as well
as conversion routines.
] [Thread Prev