17 #include <xercesc/parsers/XercesDOMParser.hpp> 18 #include <xercesc/sax/HandlerBase.hpp> 19 #include <xercesc/dom/DOM.hpp> 34 DOMNodeList* _children =
other.getDocumentConst()->getDocumentElement()->getChildNodes();
35 int _length = _children->getLength();
38 for (
int i = 0;
i != _length;
i++) {
39 _node = _children->item(
i);
40 DOMNode* i_node = this->getDocument()->importNode(_node,
true);
41 this->getDocument()->getDocumentElement()->appendChild(i_node);
78 parser =
new XercesDOMParser();
79 parser->setValidationScheme(XercesDOMParser::Val_Always);
80 parser->setDoNamespaces(
true);
82 errHandler = (ErrorHandler*)
new HandlerBase();
83 parser->setErrorHandler(errHandler);
88 }
catch (
const XMLException& toCatch) {
89 char* message = XMLString::transcode(toCatch.getMessage());
90 std::cout <<
"Exception message is: \n" << message <<
"\n";
93 }
catch (
const DOMException& toCatch) {
94 char* message = XMLString::transcode(toCatch.msg);
95 std::cout <<
"Exception message is: \n" << message <<
"\n";
104 document =
parser->getDocument();
113 parser =
new XercesDOMParser();
114 parser->setValidationScheme(XercesDOMParser::Val_Always);
115 parser->setDoNamespaces(
true);
117 errHandler = (ErrorHandler*)
new HandlerBase();
118 parser->setErrorHandler(errHandler);
123 }
catch (
const XMLException& toCatch) {
124 char* message = XMLString::transcode(toCatch.getMessage());
125 std::cout <<
"Exception message is: \n" << message <<
"\n";
128 }
catch (
const DOMException& toCatch) {
129 char* message = XMLString::transcode(toCatch.msg);
130 std::cout <<
"Exception message is: \n" << message <<
"\n";
139 document =
parser->getDocument();
148 parser =
new XercesDOMParser();
149 parser->setValidationScheme(XercesDOMParser::Val_Always);
150 parser->setDoNamespaces(
true);
152 errHandler = (ErrorHandler*)
new HandlerBase();
153 parser->setErrorHandler(errHandler);
155 DOMImplementation*
impl = DOMImplementation::getImplementation();
157 document =
impl->createDocument(
nullptr,
162 the_string =
nullptr;
197 theFileName = xmlFileName;
200 parser =
new XercesDOMParser();
201 parser->setValidationScheme(XercesDOMParser::Val_Always);
202 parser->setDoNamespaces(
true);
204 errHandler = (ErrorHandler*)
new HandlerBase();
205 parser->setErrorHandler(errHandler);
209 parser->parse(theFileName.c_str());
210 }
catch (
const XMLException& toCatch) {
211 char* message = XMLString::transcode(toCatch.getMessage());
212 std::cout <<
"Exception message is: \n" << message <<
"\n";
215 }
catch (
const DOMException& toCatch) {
216 char* message = XMLString::transcode(toCatch.msg);
217 std::cout <<
"Exception message is: \n" << message <<
"\n";
226 document =
parser->getDocument();
234 theFileName = xmlFileName;
237 parser =
new XercesDOMParser();
238 parser->setValidationScheme(XercesDOMParser::Val_Always);
239 parser->setDoNamespaces(
true);
241 errHandler = (ErrorHandler*)
new HandlerBase();
242 parser->setErrorHandler(errHandler);
246 parser->parse(theFileName.c_str());
247 }
catch (
const XMLException& toCatch) {
248 char* message = XMLString::transcode(toCatch.getMessage());
249 std::cout <<
"Exception message is: \n" << message <<
"\n";
252 }
catch (
const DOMException& toCatch) {
253 char* message = XMLString::transcode(toCatch.msg);
254 std::cout <<
"Exception message is: \n" << message <<
"\n";
263 document =
parser->getDocument();
273 theProcessor->write(
this,
target);
300 _document = document;
301 const char* _result = XMLString::transcode(
309 const char* _result = XMLString::transcode(
317 DOMDocument* _document) {
319 _document = document;
340 _document = document;
368 DOMElement* _tag = (DOMElement*)the_tag;
382 DOMElement* _tag = (DOMElement*)the_tag;
390 const int& attrValue,
393 DOMElement* _tag = (DOMElement*)the_tag;
404 DOMElement* _tag = (DOMElement*)the_tag;
413 strftime(timebuf, 50,
"%Y-%m-%d %H:%M:%S.0", gmtime(&_time));
416 return creationstamp;
425 the_string =
new std::string(XMLString::transcode(theProcessor->serializeDOM(_node, _target)));
426 return (*the_string);
475 DOMElement* _elem = document->createElement(
tagname);
476 parent->appendChild(_elem);
477 DOMText* _value = document->createTextNode(
value);
478 _elem->appendChild(_value);
int write(std::string target="stdout")
std::string getTimestamp(time_t _time)
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
std::string & getString(void)
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument(std::string xmlFileName)
XMLDOMBlock & operator+=(const XMLDOMBlock &other)
int init(std::string _root)
XERCES_CPP_NAMESPACE::DOMElement * add_element(XERCES_CPP_NAMESPACE::DOMElement *parent, XMLCh *tagname, XMLCh *value)
const char * getTagValue(const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
static XMLCh * _toXMLCh(std::string temp)
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst(void) const
static XMLProcessor * getInstance()
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
void parse(XERCES_CPP_NAMESPACE::InputSource &_source)
const char * getTagAttribute(const std::string &tagName, const std::string &attrName, int _item=0)