Hi Alexander,
At 15.24 20/07/2004 +0200, Alexander Broekhuis wrote:
Hi,
I have a LPTSTR and want to create a DOM Document from that string. I use a LPTSTR for unicode chars.
At the moment I am trying to use this: ------------------------------------------------------------------------ MemBufInputSource *memBufIS = new MemBufInputSource((const XMLByte*)xml, wcslen(xml), "xmlRecord", false); // In this line xml is the LPTSTR that contains the xml.
The MemBufInputSource works on buffers of XMLByte, so the length must be in bytes; wcslen returns the number of wchar_t (or XMLCh, on Windows), so you need to multiply it by 2. Or, to be on the safe side, you should always use TCHAR-based code, like this
MemBufInputSource *memBufIS = new MemBufInputSource((const XMLByte*)xml, _tcslen(xml)*sizeof(TCHAR), "xmlRecord", false);
Alberto
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS); DOMBuilder *parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0); Wrapper4InputSource* domBufIS = NULL; domBufIS = new Wrapper4InputSource ( memBufIS ); XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc = parser->parse(*domBufIS); DOMElement * root = doc->getDocumentElement(); ------------------------------------------------------------------------
This piece of code fails when it tries to parse the domBufIS and wants to create a DOMDocument. If I debug this code the XMLByte from MemBufInputSource seems to have only the first char from xml (a "<").
Are there better/other ways to create a DOMDocument from a LPTSTR?
TiA,
Alexander
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]