> I am currently trying to extract an attribute's string of an XML node
with the
> following code.
> std::string value =
XMLString::transcode(node->getAttributes()->getNamedItem(XMLString::transcode("mapstyle"))->getNodeValue());
>
> Whatever the encoding format is in the XML file header, I retreive empty
> strings when the value includes french accents such as : "���..."
First of all, XMLString::transcode() return memory that is dynamically
allocated, so you are leaking memory twice in this line of code.
Second, you should not transcode to the local code page, because you have
no guarantee that all of the characters in your XML document can be
represented. If they cannot, as you have discovered, the results are not
predictable. Since it looks like you want to store the attribute value in
an instance of std::string, you will need to choose a byte-oriented
encoding, and create and use a transcoder for that particular encoding.
The best choice is UTF-8, because it can represent all possible Uniocde
characters. Another choice might be ISO-8859-1, since that can represent
most of the characters used in Western European languages.
If you search the archives of the mailing list, you will see many
discussions of this issue. If you search the source code, you will find
code that creates and uses a transcoder. The header file
src/xercesc/util/TransService.hpp is the place to start.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]