Hi Alexander,

At 12.37 22/07/2004 +0200, Alexander Broekhuis wrote:
Hi,

I wrote an ErrorHandler, and get an error on line 2 char 1. The string I
use is a wstring:

wstring record = L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        record += L"<auditTrailRecord type=\"test\">\n";
        record += L"<test></test>\n";
        record += L"</auditTrailRecord>\n";

When I want to parse it I create a MemBufInputSrc. The fSrcBytes contain
the complete string. Why can't it parse this string?

If I parse this string to a char * nothing is wrong. So it has something
to do with that string being unicode.

You have a hint here...;-)
You are storing the buffer inside a wstring, so it's represented in memory as Unicode (16 or 32 bit per char, depending on the platform you are on); but the XML says it's UTF-8 inside, so Xerces will start treating the buffer as UTF-8 starting from the offset where "<auditTrailRecord" is.
One solution is not to specify the encoding="UTF-8" part, and let Xerces autodetect the encoding; another solution is to force Xerces to ignore the encoding by calling


    MemBufInputSource *memBufIS = new MemBufInputSource(pXMLByte, i,
"xmlRecord", false);
    memBufIS->setEncoding(L"UTF-16LE");

(I assumed you are on Windows; otherwise the encoding could be different)

Alberto



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to