Xerces getXML method
-
ladies & gentlemen. i'm new in xerces xml dom. can anyone help me with following: how can i get the XML content of the DOMDocument (as in msxml)? there methods like, getTextContent... but it returns text without tags. i've seen that java implemantation of xerces has DOMSerializer object. maybe there is any analogical object... any ideas? 4apai There're no impossible tasks. There're tasks that required infinite period of execution time.
-
ladies & gentlemen. i'm new in xerces xml dom. can anyone help me with following: how can i get the XML content of the DOMDocument (as in msxml)? there methods like, getTextContent... but it returns text without tags. i've seen that java implemantation of xerces has DOMSerializer object. maybe there is any analogical object... any ideas? 4apai There're no impossible tasks. There're tasks that required infinite period of execution time.
int main(int argc, char **argv) { int errorCount = 0; try { XMLPlatformUtils::Initialize(); } catch(const XMLException& toCatch) { cout << "XMLPlatformUtils::Initialize() failed." << endl; XMLPlatformUtils::Terminate(); } std::auto_ptr pXercesDOMParser(new XercesDOMParser()); std::auto_ptr errReporter(new myDOMTreeErrorReporter()); pXercesDOMParser->setErrorHandler(errReporter.get()); XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Auto; pXercesDOMParser->setValidationScheme(valScheme); try { char filename[] = "config/command.xml"; pXercesDOMParser->parse(filename); errorCount = pXercesDOMParser->getErrorCount(); if (errorCount > 0) { cout << "open file failed. 0" << endl; XMLPlatformUtils::Terminate(); //goto Exit; return 0; } } catch (const DOMException& e) { cout << "open file failed. 1" << endl; XMLPlatformUtils::Terminate(); return 0; } catch (const XMLException& e) { cout << "open file failed. 2" << endl; XMLPlatformUtils::Terminate(); return 0; } DOMNode *pDOC = pXercesDOMParser->getDocument(); DOMNode *pNode = pDOC->getFirstChild(); //std::string name(getProp(pNode, "?xml")); for (pNode = getNextElementNode(pNode); pNode != NULL; pNode = getNextElementNode(pNode)) { /*if (!UtilXML::matchNode(pNode, "dictionary"); if (!matchNode(pNode, "dictionary")) { cout << "Bad dictionary format." << endl; break; } std::string proto(getProp(pNode, "protocol")); int currentProtocol = atol(proto.c_str()); #ifdef _DEBUG cout << "protocol = " << currentProtocol << endl; #endif parseDictionary(pNode->getFirstChild(), currentProtocol); */ if(!matchNode(pNode, "command")) { cout << "Bad command format." << endl; break; } parseCommand(pNode, 0); } //Exit: pXercesDOMParser.release(); errReporter.release(); XMLPlatformUtils::Terminate(); return 0; }
-
int main(int argc, char **argv) { int errorCount = 0; try { XMLPlatformUtils::Initialize(); } catch(const XMLException& toCatch) { cout << "XMLPlatformUtils::Initialize() failed." << endl; XMLPlatformUtils::Terminate(); } std::auto_ptr pXercesDOMParser(new XercesDOMParser()); std::auto_ptr errReporter(new myDOMTreeErrorReporter()); pXercesDOMParser->setErrorHandler(errReporter.get()); XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Auto; pXercesDOMParser->setValidationScheme(valScheme); try { char filename[] = "config/command.xml"; pXercesDOMParser->parse(filename); errorCount = pXercesDOMParser->getErrorCount(); if (errorCount > 0) { cout << "open file failed. 0" << endl; XMLPlatformUtils::Terminate(); //goto Exit; return 0; } } catch (const DOMException& e) { cout << "open file failed. 1" << endl; XMLPlatformUtils::Terminate(); return 0; } catch (const XMLException& e) { cout << "open file failed. 2" << endl; XMLPlatformUtils::Terminate(); return 0; } DOMNode *pDOC = pXercesDOMParser->getDocument(); DOMNode *pNode = pDOC->getFirstChild(); //std::string name(getProp(pNode, "?xml")); for (pNode = getNextElementNode(pNode); pNode != NULL; pNode = getNextElementNode(pNode)) { /*if (!UtilXML::matchNode(pNode, "dictionary"); if (!matchNode(pNode, "dictionary")) { cout << "Bad dictionary format." << endl; break; } std::string proto(getProp(pNode, "protocol")); int currentProtocol = atol(proto.c_str()); #ifdef _DEBUG cout << "protocol = " << currentProtocol << endl; #endif parseDictionary(pNode->getFirstChild(), currentProtocol); */ if(!matchNode(pNode, "command")) { cout << "Bad command format." << endl; break; } parseCommand(pNode, 0); } //Exit: pXercesDOMParser.release(); errReporter.release(); XMLPlatformUtils::Terminate(); return 0; }