17 #include <xercesc/parsers/XercesDOMParser.hpp>
18 #include <xercesc/sax/HandlerBase.hpp>
19 #include <xercesc/dom/DOM.hpp>
26 XERCES_CPP_NAMESPACE_USE
37 DOMNodeList * _children = other.
getDocumentConst()->getDocumentElement()->getChildNodes();
38 int _length = _children->getLength();
41 for(
int i=0;
i!=_length;
i++){
42 _node = _children->item(
i);
43 DOMNode * i_node = this->getDocument()->importNode(_node,
true);
44 this->getDocument()->getDocumentElement()->appendChild(i_node);
86 parser =
new XercesDOMParser();
87 parser->setValidationScheme(XercesDOMParser::Val_Always);
88 parser->setDoNamespaces(
true);
90 errHandler = (ErrorHandler*)
new HandlerBase();
91 parser->setErrorHandler(errHandler);
98 catch (
const XMLException& toCatch) {
99 char*
message = XMLString::transcode(toCatch.getMessage());
105 catch (
const DOMException& toCatch) {
106 char* message = XMLString::transcode(toCatch.msg);
118 document =
parser -> getDocument();
130 parser =
new XercesDOMParser();
131 parser->setValidationScheme(XercesDOMParser::Val_Always);
132 parser->setDoNamespaces(
true);
134 errHandler = (ErrorHandler*)
new HandlerBase();
135 parser->setErrorHandler(errHandler);
142 catch (
const XMLException& toCatch) {
143 char* message = XMLString::transcode(toCatch.getMessage());
149 catch (
const DOMException& toCatch) {
150 char* message = XMLString::transcode(toCatch.msg);
162 document =
parser -> getDocument();
174 parser =
new XercesDOMParser();
175 parser->setValidationScheme(XercesDOMParser::Val_Always);
176 parser->setDoNamespaces(
true);
178 errHandler = (ErrorHandler*)
new HandlerBase();
179 parser->setErrorHandler(errHandler);
181 DOMImplementation* impl = DOMImplementation::getImplementation();
183 document = impl->createDocument(
230 parser =
new XercesDOMParser();
231 parser->setValidationScheme(XercesDOMParser::Val_Always);
232 parser->setDoNamespaces(
true);
234 errHandler = (ErrorHandler*)
new HandlerBase();
235 parser->setErrorHandler(errHandler);
240 parser->parse( theFileName . c_str() );
242 catch (
const XMLException& toCatch) {
243 char* message = XMLString::transcode(toCatch.getMessage());
249 catch (
const DOMException& toCatch) {
250 char* message = XMLString::transcode(toCatch.msg);
262 document =
parser -> getDocument();
275 parser =
new XercesDOMParser();
276 parser->setValidationScheme(XercesDOMParser::Val_Always);
277 parser->setDoNamespaces(
true);
279 errHandler = (ErrorHandler*)
new HandlerBase();
280 parser->setErrorHandler(errHandler);
285 parser->parse( theFileName . c_str() );
287 catch (
const XMLException& toCatch) {
288 char* message = XMLString::transcode(toCatch.getMessage());
294 catch (
const DOMException& toCatch) {
295 char* message = XMLString::transcode(toCatch.msg);
307 document =
parser -> getDocument();
324 theProcessor ->
write(
this, target );
352 if (!_document) _document = document;
353 const char * _result = XMLString::transcode( _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild()-> getNodeValue() );
359 if (!_document)
return 0;
360 const char * _result = XMLString::transcode( _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild()-> getNodeValue() );
366 if (!_document) _document = document;
367 DOMNode * the_tag = _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
374 if (!_elem)
return 0;
384 if (!_document) _document = document;
385 DOMNode * the_tag = _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
392 if (!_elem)
return 0;
402 DOMElement * _tag = (DOMElement *)(document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ));
403 const char * _result = XMLString::transcode( _tag -> getAttribute(
XMLProcessor::_toXMLCh( attrName ) ) );
410 DOMNode * the_tag = document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
411 DOMElement * _tag = (DOMElement *)the_tag;
418 if (!_elem)
return 0;
421 DOMElement * _tag = (DOMElement *)the_tag;
429 DOMNode * the_tag = document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
430 DOMElement * _tag = (DOMElement *)the_tag;
437 if (!_elem)
return 0;
440 DOMElement * _tag = (DOMElement *)the_tag;
450 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S.0", gmtime( &_time ) );
453 return creationstamp;
461 return getString( this->getDocument() );
469 if (the_string)
delete the_string;
471 the_string =
new std::string( XMLString::transcode( theProcessor->serializeDOM(_node,_target) ) );
472 return (*the_string);
524 DOMElement * _elem = document -> createElement( tagname );
525 parent -> appendChild(_elem);
526 DOMText * _value = document -> createTextNode(value);
527 _elem->appendChild(_value);
int write(std::string target="stdout")
std::string getTimestamp(time_t _time)
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst(void) const
std::string & getString(void)
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument(std::string xmlFileName)
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
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)
static XMLCh * _toXMLCh(std::string temp)
const char * getTagValue(const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
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)