It's ok but not print the node value.
I don't understand.
What is my error? Thanks
- Code: Select all
#include <stdlib.h>
#include <iostream>
#include <Poco/XML/XMLString.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Node.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/DOMParser.h>
using namespace std;
int main(int argc, char** argv) {
Poco::XML::DOMParser *domParser = new Poco::XML::DOMParser();
Poco::XML::Document *doc = NULL;
Poco::XML::Node *node = NULL;
Poco::XML::NodeList *nodeList = NULL;
Poco::XML::XMLString *iFile = new Poco::XML::XMLString("book.xml");
Poco::XML::XMLString *tagTitle = new Poco::XML::XMLString("title");
doc = domParser->parse(*iFile);
nodeList = doc->getElementsByTagName(*tagTitle);
node = nodeList->item(0);
cout << node->nodeName() << ": " << node->nodeValue() << endl;
return (EXIT_SUCCESS);
}
Xml file is:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "book.dtd">
<books>
<book>
<title><![CDATA[L'eretico]]></title>
</book>
</books>
DTD file is:
- Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<!ELEMENT books (book)*>
<!ELEMENT book (title)*>
<!ELEMENT title (#PCDATA)>





