www.pudn.com > xml_ptr.zip > XmlHandler.h
#pragma once #include #include #include #include using namespace std; typedef map > AttributeMap; class Node; typedef map > NodeMap; struct DeleteObject { template void operator()(const T& ptr)const { delete ptr.second; } } ; class Node { private: public: Node(); Node(const string& name); Node(const string& name, const string& val); Node(const string& name, const string& val, const string& key); ~Node(); void setNode(const string& key, Node* val); void setVal(const string& val); void setKey(const string& key); public: string _name; string _val; string _key; AttributeMap _attrMap; NodeMap _nodeMap; }; class XmlTree { private: NodeMap _nodeMap; Node *root; public: XmlTree(); ~XmlTree(); XmlTree(const XmlTree& org); bool insertNode(Node* pNode, Node* cNode); Node* findNode(Node* pNode, const string& key); Node* findNode(Node* pNode, const Node* cNode); static bool readXmlFile(const string& fileName, string& content); static XmlTree* createXmlTree(string& content); std::string printInfo(Node* pNode); void printInfo(ostream& out); friend ostream& operator <<(ostream&, XmlTree&); } ;