18 #include <xercesc/parsers/XercesDOMParser.hpp>
19 #include <xercesc/sax/HandlerBase.hpp>
20 #include <xercesc/dom/DOM.hpp>
27 XERCES_CPP_NAMESPACE_USE
38 DOMNodeList * _children = other.
getDocumentConst()->getDocumentElement()->getChildNodes();
39 int _length = _children->getLength();
43 _node = _children->item(
i);
44 DOMNode * i_node = this->getDocument()->importNode(_node,
true);
45 this->getDocument()->getDocumentElement()->appendChild(i_node);
87 parser =
new XercesDOMParser();
88 parser->setValidationScheme(XercesDOMParser::Val_Always);
89 parser->setDoNamespaces(
true);
91 errHandler = (ErrorHandler*)
new HandlerBase();
92 parser->setErrorHandler(errHandler);
99 catch (
const XMLException& toCatch) {
100 char*
message = XMLString::transcode(toCatch.getMessage());
106 catch (
const DOMException& toCatch) {
107 char*
message = XMLString::transcode(toCatch.msg);
119 document =
parser -> getDocument();
131 parser =
new XercesDOMParser();
132 parser->setValidationScheme(XercesDOMParser::Val_Always);
133 parser->setDoNamespaces(
true);
135 errHandler = (ErrorHandler*)
new HandlerBase();
136 parser->setErrorHandler(errHandler);
143 catch (
const XMLException& toCatch) {
144 char*
message = XMLString::transcode(toCatch.getMessage());
150 catch (
const DOMException& toCatch) {
151 char*
message = XMLString::transcode(toCatch.msg);
163 document =
parser -> getDocument();
175 parser =
new XercesDOMParser();
176 parser->setValidationScheme(XercesDOMParser::Val_Always);
177 parser->setDoNamespaces(
true);
179 errHandler = (ErrorHandler*)
new HandlerBase();
180 parser->setErrorHandler(errHandler);
182 DOMImplementation* impl = DOMImplementation::getImplementation();
184 document = impl->createDocument(
231 parser =
new XercesDOMParser();
232 parser->setValidationScheme(XercesDOMParser::Val_Always);
233 parser->setDoNamespaces(
true);
235 errHandler = (ErrorHandler*)
new HandlerBase();
236 parser->setErrorHandler(errHandler);
241 parser->parse( theFileName . c_str() );
243 catch (
const XMLException& toCatch) {
244 char*
message = XMLString::transcode(toCatch.getMessage());
250 catch (
const DOMException& toCatch) {
251 char*
message = XMLString::transcode(toCatch.msg);
263 document =
parser -> getDocument();
276 parser =
new XercesDOMParser();
277 parser->setValidationScheme(XercesDOMParser::Val_Always);
278 parser->setDoNamespaces(
true);
280 errHandler = (ErrorHandler*)
new HandlerBase();
281 parser->setErrorHandler(errHandler);
286 parser->parse( theFileName . c_str() );
288 catch (
const XMLException& toCatch) {
289 char*
message = XMLString::transcode(toCatch.getMessage());
295 catch (
const DOMException& toCatch) {
296 char*
message = XMLString::transcode(toCatch.msg);
308 document =
parser -> getDocument();
325 theProcessor ->
write(
this, target );
353 if (!_document) _document = document;
354 const char * _result = XMLString::transcode( _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild()-> getNodeValue() );
360 if (!_document)
return 0;
361 const char * _result = XMLString::transcode( _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild()-> getNodeValue() );
367 if (!_document) _document = document;
368 DOMNode * the_tag = _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
375 if (!_elem)
return 0;
385 if (!_document) _document = document;
386 DOMNode * the_tag = _document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
393 if (!_elem)
return 0;
403 DOMElement * _tag = (DOMElement *)(document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ));
404 const char * _result = XMLString::transcode( _tag -> getAttribute(
XMLProcessor::_toXMLCh( attrName ) ) );
411 DOMNode * the_tag = document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
412 DOMElement * _tag = (DOMElement *)the_tag;
419 if (!_elem)
return 0;
422 DOMElement * _tag = (DOMElement *)the_tag;
430 DOMNode * the_tag = document -> getElementsByTagName(
XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
431 DOMElement * _tag = (DOMElement *)the_tag;
438 if (!_elem)
return 0;
441 DOMElement * _tag = (DOMElement *)the_tag;
451 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S.0", gmtime( &_time ) );
452 std::string creationstamp = timebuf;
454 return creationstamp;
462 return getString( this->getDocument() );
470 if (the_string)
delete the_string;
471 std::string _target =
"string";
472 the_string =
new std::string( XMLString::transcode( theProcessor->serializeDOM(_node,_target) ) );
473 return (*the_string);
525 DOMElement * _elem = document -> createElement( tagname );
526 parent -> appendChild(_elem);
527 DOMText * _value = document -> createTextNode(value);
528 _elem->appendChild(_value);
int write(std::string target="stdout")
std::string getTimestamp(time_t _time)
DOMDocument * getDocumentConst(void) const
std::string & getString(void)
DOMDocument * getDocument(void)
DOMDocument * getNewDocument(std::string xmlFileName)
XMLDOMBlock & operator+=(const XMLDOMBlock &other)
int init(std::string _root)
static XMLCh * _toXMLCh(std::string temp)
DOMElement * add_element(DOMElement *parent, XMLCh *tagname, XMLCh *value)
void parse(InputSource &_source)
const char * getTagValue(const std::string &tagName, int _item=0, DOMDocument *_document=NULL)
DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, DOMDocument *_document=NULL)
static XMLProcessor * getInstance()
DOMNode * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
const char * getTagAttribute(const std::string &tagName, const std::string &attrName, int _item=0)