00001 // @(#)root/xmlparser:$Id: TXMLNode.h 21809 2008-01-22 16:11:46Z brun $ 00002 // Author: Jose Lo 12/4/2005 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef ROOT_TXMLNode 00013 #define ROOT_TXMLNode 00014 00015 ////////////////////////////////////////////////////////////////////////// 00016 // // 00017 // TXMLNode // 00018 // // 00019 // TXMLNode contains a pointer to xmlNode, which is a node under the // 00020 // DOM tree. A node can be an Element, an Attribute, a Text Node // 00021 // or a Comment Node. // 00022 // One can navigate the DOM tree by accessing the siblings and // 00023 // parent or child nodes. Also retriving the Attribute or the Text in // 00024 // an Element node. // 00025 // // 00026 ////////////////////////////////////////////////////////////////////////// 00027 00028 00029 #ifndef ROOT_TObject 00030 #include "TObject.h" 00031 #endif 00032 00033 #ifndef ROOT_TString 00034 #include "TString.h" 00035 #endif 00036 00037 class TList; 00038 struct _xmlNode; 00039 00040 class TXMLNode : public TObject { 00041 00042 private: 00043 TXMLNode(const TXMLNode&); // Not implemented 00044 TXMLNode& operator=(const TXMLNode&); // Not implemented 00045 00046 _xmlNode *fXMLNode; // libxml node 00047 00048 TXMLNode *fParent; // Parent node 00049 TXMLNode *fChildren; // Children node 00050 TXMLNode *fNextNode; // Next sibling node 00051 TXMLNode *fPreviousNode; // Previous sibling node 00052 TList *fAttrList; // List of Attributes 00053 00054 public: 00055 // This enum is based on libxml tree Enum xmlElementType 00056 enum EXMLElementType { 00057 kXMLElementNode = 1, 00058 kXMLAttributeNode = 2, 00059 kXMLTextNode = 3, 00060 kXMLCommentNode = 8 00061 }; 00062 00063 TXMLNode(_xmlNode *node, TXMLNode* parent=0, TXMLNode* previous=0); 00064 00065 virtual ~TXMLNode(); 00066 00067 EXMLElementType GetNodeType() const; 00068 const char *GetNodeName() const; 00069 TXMLNode *GetChildren(); 00070 TXMLNode *GetParent() const; 00071 TXMLNode *GetNextNode(); 00072 TXMLNode *GetPreviousNode() const; 00073 const char *GetContent() const; 00074 const char *GetText() const; 00075 TList *GetAttributes(); 00076 00077 Bool_t HasChildren() const; 00078 Bool_t HasNextNode() const; 00079 Bool_t HasParent() const; 00080 Bool_t HasPreviousNode() const; 00081 Bool_t HasAttributes() const; 00082 00083 const char *GetNamespaceHref() const; 00084 const char *GetNamespacePrefix() const; 00085 00086 ClassDef(TXMLNode,0); // XML node under DOM tree 00087 }; 00088 00089 #endif