Skip to content

Instantly share code, notes, and snippets.

@Mandar-Shinde
Last active April 25, 2022 14:51
Show Gist options
  • Save Mandar-Shinde/df80f71a014733530975479b29bc79ae to your computer and use it in GitHub Desktop.
Save Mandar-Shinde/df80f71a014733530975479b29bc79ae to your computer and use it in GitHub Desktop.
poco xml dom parsing
using Poco::XML::DOMParser;
using Poco::XML::InputSource;
using Poco::XML::Document;
using Poco::XML::NodeIterator;
using Poco::XML::NodeFilter;
using Poco::XML::Node;
using Poco::XML::AutoPtr;
using Poco::Exception;
Poco::XML::DOMParser parser;
Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parseString("<?xml version=\"1.0\" encoding=\"UTF-8\"?> <note> <to>mandar</to> <from>nativeMessage</from> <heading>Reminder</heading> <body>Calling C++ app</body> </note>");
Poco::XML::Node *nod = pDoc->getNodeByPath("/note/to");
if (nod != NULL)
std::cout << nod->firstChild()->innerText()<<std::endl;
nod = pDoc->getNodeByPath("/note/from");
if (nod != NULL)
std::cout << nod->firstChild()->innerText() << std::endl;
nod = pDoc->getNodeByPath("/note/body");
if (nod != NULL)
std::cout << nod->firstChild()->innerText() << std::endl;
nod = pDoc->getNodeByPath("/note/heading");
if (nod != NULL)
std::cout << nod->firstChild()->innerText() << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment