Details
Description
#include <stdio.h>
#include <string>
#include <iostream>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/AbstractDOMParser.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>
#include <xercesc/dom/DOMBuilder.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMNodeList.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMLocator.hpp>
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#ifdef XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_USE
#endif
int read_url(std::string const & url_str){
int rc = 0;
xercesc::XercesDOMParser * parser;
xercesc::DOMDocument *m_pDoc;
bool bRecognizeNEL;
xercesc::AbstractDOMParser::ValSchemes valScheme;
bool bDoNamespaces;
bool bDoSchema;
bool bSchemaFullChecking;
bool bDatatypeNormalization;
bool bCreateEntityReferenceNodes;
bRecognizeNEL = false;
valScheme = AbstractDOMParser::Val_Auto;
bDoNamespaces = false;
bDoSchema = false;
bSchemaFullChecking = false;
bCreateEntityReferenceNodes = false;
bDatatypeNormalization = true;
// Initialize the XML4C system
try
catch (const XMLException& toCatch){}
parser = new XercesDOMParser();
parser->setValidationScheme(valScheme);
parser->setDoNamespaces(bDoNamespaces);
parser->setDoSchema(bDoSchema);
parser->setValidationSchemaFullChecking(bSchemaFullChecking);
parser->setCreateEntityReferenceNodes(bCreateEntityReferenceNodes);
try
{ XMLURL url(url_str.c_str()); URLInputSource src(url); // reset document pool parser->resetDocumentPool(); parser->parse(src); m_pDoc = parser->getDocument(); }catch(...)
{ rc = -1; } if(parser)delete parser;
// And call the termination method
XMLPlatformUtils::Terminate();
return rc;
}
int main(){
while(1)
{ read_url("http://127.0.0.1/abcd/op1.xml"); sleep(2); }return 0;
}