00001 #ifndef ots_XmlDocument_h
00002 #define ots_XmlDocument_h
00003
00004 #include <xercesc/parsers/XercesDOMParser.hpp>
00005 #include <xercesc/dom/DOMElement.hpp>
00006 #include <vector>
00007 #include <string>
00008
00009 namespace ots
00010 {
00011
00012 class XmlDocument
00013 {
00014 public:
00015
00016 XmlDocument(std::string rootName="ROOT");
00017 XmlDocument(const XmlDocument& doc);
00018 XmlDocument& operator=(const XmlDocument& doc);
00019 ~XmlDocument(void);
00020
00021 xercesc::DOMElement* addTextElementToParent (std::string childName, std::string childText, xercesc::DOMElement* parent);
00022 xercesc::DOMElement* addTextElementToParent (std::string childName, std::string childText, std::string parentName, unsigned int parentIndex=0);
00023
00024 void saveXmlDocument (std::string filePath);
00025 void recursiveRemoveChild (xercesc::DOMElement *childEl,xercesc::DOMElement *parentEl);
00026
00027
00028 bool loadXmlDocument (std::string filePath);
00029
00030 void outputXmlDocument (std::ostringstream *out, bool dispStdOut=false);
00031
00032 protected:
00033 void copyDocument (const xercesc::DOMDocument* toCopy, xercesc::DOMDocument* copy);
00034 void recursiveElementCopy (const xercesc::DOMElement* toCopy, xercesc::DOMElement* copy);
00035 void initDocument (void);
00036 void initPlatform (void);
00037 void terminatePlatform (void);
00038 void recursiveOutputXmlDocument (xercesc::DOMElement *currEl, std::ostringstream *out, bool dispStdOut=false, std::string tabStr="");
00039
00040
00041
00042
00043
00044 std::string escapeString (std::string inString, bool allowWhiteSpace=false);
00045
00046 xercesc::DOMImplementation* theImplementation_;
00047 xercesc::DOMDocument* theDocument_;
00048 xercesc::DOMElement* rootElement_;
00049
00050 const std::string rootTagName_;
00051 };
00052
00053 }
00054
00055 #endif //ots_XmlDocument_h