Witam,
chcę zrobić DOMDocument z XML-owego stringa za pomocą Xerces Api.
już mam dość tego... :-( w javie 2 min i po sprawie włączając czas na szukanie jak to zrobić, a tutaj siedze i siedze i nic...
Mam taką metodę:
DOMDocument* createDocument(const std::string string){
XMLCh tempStr[100];
XMLString::transcode("LS", tempStr, 99);
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMBuilder* parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
MemBufInputSource* memBufIS = new MemBufInputSource((const XMLByte*)string.c_str(), string.size(), "", false);
Wrapper4InputSource *wrapper = new Wrapper4InputSource(memBufIS,false);
DOMDocument *doc = NULL;
try {
parser->resetDocumentPool();
doc=parser->parse(*wrapper);
}catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
printf("Exception Message is :\n %s",message);
XMLString::release(&message);
return NULL;
}catch (const DOMException& toCatch) {
char* message = XMLString::transcode(toCatch.msg);
printf("Exception message is :\n %s",message);
XMLString::release(&message);
return NULL;
}catch (...) {
printf("UnExpected Exception \n");
return NULL;
}
parser->release();
return doc;
}
string jest przerzucany do MemBufInputSource i potem obudowany Wrapper4InputSource.
Linia : doc=parser->parse(*wrapper);
powinna wygenerowac mi dokument. Owszem doc!=NULL ale doc->getDocumentElement() jest nullem.
Exception nie lecą...
Help, to nie może być trudne przecież :-/