Andrew Patterson wrote:
I am not sure I understood what you asked, but I think you need to use
MemBufInputSource; see the MemParse sample for an example of its usage.
I'm working on something similar -- I posted here a month or so back
about it -- and I can't get it to work either. I looked at MemParse.cpp
but it's using a SAX parser and I need DOM -- so the sample has some
usefulness, but is obviously different.
Here's what I'm trying:
--------------------
const XMLByte foo[256] = "<foo>Testing</foo>";
int size = strlen((char*)foo);
MemBufInputSource* stringSource = new MemBufInputSource(foo, size,
"ignored", false);
assert(stringSource);
try {
Wrapper4InputSource source(stringSource);
m_parser->parseWithContext(source, &node,
DOMBuilder::ACTION_APPEND_AS_CHILDREN);
} catch (DOMException& e) {
printf("EXCEPTION: '%s'\n", e.getMessage());
}
--------------------
node is a DOMNode& that's been passed in as the place to attached the
resultant DOM fragment & m_parser is a DOMBuilder*. I'm obviously doing
*something* wrong, but the exception I get is extremely unhelpful. The
output I get is "EXCEPTION: 'T'" -- not the most informative message ^_^
I don't know what the problem is with the DOMBuilder, but it's clear why
the exception message is not printed properly. If you check the return type
from DOMException::getMessage(), you'll see it's "const XMLCh*" which means
it's a UTF-16 string. Unfortunately, you've told sprintf that the
parameter is "const char*" so you won't get anything interesting as a result.
Look in the documentation for XMLString::transcode() to see how you can
transcode the UTF-16 string to the local code page.
Dave