00001 00002 00003 #ifndef XMLNODE_H 00004 #define XMLNODE_H 00005 00006 00007 #include "libxml/parser.h" 00008 #include "libxml/xpath.h" 00009 00010 #include <string> 00011 #include <vector> 00012 00013 00014 namespace xml { 00015 00016 00017 class CXMLNameSpace; 00018 00019 00020 class CXMLAttribute { 00021 public: 00023 // Constructor 00025 CXMLAttribute(void); 00026 CXMLAttribute(xmlAttr *attribute); 00027 00028 00030 // Destructor 00032 virtual ~CXMLAttribute(void); 00033 00035 // Functions 00037 void print(void); 00038 00039 00041 // Variables 00043 std::string m_name; 00044 std::string m_value; 00045 }; 00046 00047 00048 class CXMLAttributeList { 00049 public: 00051 // Constructor 00053 CXMLAttributeList(void); 00054 00055 00057 // Destructor 00059 virtual ~CXMLAttributeList(void); 00060 00061 00063 // Functions 00065 int getSize(void); 00066 void add(CXMLAttribute element); 00067 CXMLAttribute get(int index); 00068 void clear(void); 00069 00070 00072 // Variables 00074 std::vector<CXMLAttribute> m_attList; 00075 }; 00076 00077 00078 class CXMLNode { 00079 public: 00081 // Constructor 00083 CXMLNode(void); 00084 CXMLNode(xmlNodePtr node); 00085 00086 00088 // Destructor 00090 virtual ~CXMLNode(void); 00091 00092 00094 // Functions 00096 bool getName(std::string *destination); 00097 int getType(void); 00098 00100 00105 bool getFirstChildNode(CXMLNode *destination); 00106 00108 00113 bool getNextSiblingNode(CXMLNode *destination); 00114 00115 bool getNameSpace(CXMLNameSpace *destination); 00116 00117 bool hasNameSpace(void); 00118 00119 bool getContent(std::string *destination); 00120 00122 00126 bool getFirstDescendantByName(const std::string &name, CXMLNode *node); 00127 00129 00134 bool getText(std::string *destination); 00135 00137 00140 bool getAttributes(CXMLAttributeList *destination); 00141 00143 00146 bool getAttributeByName(const std::string &attrName, CXMLAttribute *destination); 00147 00149 void print(bool recursive = false); 00150 00151 00152 private: 00154 // Functions 00156 static xmlNodePtr getFirstDescendantByNamexmlPtr(const std::string &name, xmlNodePtr current); 00157 00158 00160 // Variables 00162 xmlNode *m_node; 00163 }; 00164 00165 00166 class CXMLNodeSet { 00167 public: 00169 // Constructor 00171 CXMLNodeSet(void); 00172 CXMLNodeSet(xmlNodeSetPtr nodeSet); 00173 CXMLNodeSet(xmlXPathObjectPtr object); 00174 00175 00177 // Destructor 00179 virtual ~CXMLNodeSet(void); 00180 00181 00183 // Functions 00185 int getNodeNum(void); 00186 bool getNodeAt(int index, CXMLNode *destination); 00187 void print(void); 00188 00189 00190 private: 00192 // Variables 00194 xmlNodeSetPtr m_nodeSet; 00195 xmlXPathObjectPtr m_xpathObject; 00196 }; 00197 }; 00198 00199 #endif