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.
Alexander
This is the code I use:
-----------------------------------------------------------------------------
XMLByte *pXMLByte = reinterpret_cast<XMLByte*> (static_cast<LPTSTR>(xml));
int i = wcslen(xml)*sizeof(TCHAR);
MemBufInputSource *memBufIS = new MemBufInputSource(pXMLByte, i,
"xmlRecord", false);
//char *pmbbuf = (char *)malloc( wcslen(xml) );
//wcstombs(pmbbuf, xml, wcslen(xml)+1);
//MemBufInputSource *memBufIS = new MemBufInputSource((const
XMLByte*)pmbbuf, strlen(pmbbuf), "xmlRecord", false);
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
XercesDOMParser* parser = new XercesDOMParser();
MemParseHandlers errorHandler;
parser->setErrorHandler(&errorHandler);
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc = NULL;
try {
parser->parse(*memBufIS);
doc = parser->getDocument();
cout << "parsed the file" << endl;
} catch (SAXException & e) {
cerr << "sax error" << endl;
cerr << e.getMessage() << endl;
} catch (DOMException & e) {
cerr << "DoM error" << endl;
} catch (XMLException & e) {
cerr << "XML error" << endl;
cerr << e.getMessage() << endl;
} catch (...) {
cerr << "Error" << endl;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]