Last active
April 25, 2022 14:51
-
-
Save Mandar-Shinde/df80f71a014733530975479b29bc79ae to your computer and use it in GitHub Desktop.
poco xml dom parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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