Hi everyone,
I'm trying to import an XML file parsed with XercesDOMParser into my main
DOMDocument as following:
/*#####################################################
*Parse the file to add
*/
itsParser = new XercesDOMParser();
itsParser->setDoNamespaces(true);
itsParser->setDoSchema(true);
itsParser->setValidationScheme(XercesDOMParser::Val_Always);
itsParser->setExternalNoNamespaceSchemaLocation("mySchema.sxd");
// Instancie un ErrorHandler et le lie au parser
itsErrHandler = new ErrReporter();
itsParser->setErrorHandler(itsErrHandler);
/* Create the document */
DOMDocument* domdoc = impl->createDocument(NULL, NULL, NULL);
// Parse le fichier XML et récupère le temps mis pour le parsing
try {
itsParser->resetDocumentPool();
const unsigned long startMillis =
XMLPlatformUtils::getCurrentMillis();
itsParser->parse("myXML.xml");
if (itsParser->getErrorCount() == 0) {
domdoc = itsParser->getDocument();
}
else {
LINFO("Error when attempting to parse the XML file ");
}
}
// Exception XML
catch (const XMLException& err) {
LINFO("Erreur XML pendant le parsing du fichier : %s ",
inputXML);
}
// Exception DOM
catch (const DOMException& err) {
const unsigned int maxChars = 2047;
XMLCh errText[maxChars + 1];
LINFO("Erreur DOM pendant le parsing du fichier : %s \n",
inputXML);
if (DOMImplementation::loadDOMExceptionMsg(err.code, errText,
maxChars))
LFATAL("Exception DOM : %s ",
XMLString::transcode(errText));
} catch (...) {
LINFO("Erreur inattendue durant le parsing du fichier : %s",
inputXML);
}
/*#####################################################
* End Parsing */
/*#####################################################
* add it to an other DOMDocument
*/
XMLCh* rootvalue = XMLString::transcode("MainRoot");
DOMDocument* mainDOM = impl->createDocument(NULL, rootvalue, NULL);
XMLString::release(&rootvalue);
DOMNode* domnode = domdoc->getDocumentElement();
DOMElement* root = itsXMLdoc->getDocumentElement();
root->importNode(domnode, true);
/*#####################################################
* End adding XML */
What am I doing wrong ?
thanks so much for all your help,
Jerome
--
View this message in context:
http://www.nabble.com/DOMDocument%3A%3AimportNode%28%29-tf4119877.html#a11717007
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]