Logo ROOT   6.08/07
Reference Guide
TXMLDocument.cxx
Go to the documentation of this file.
1 // @(#)root/xmlparser:$Id$
2 // Author: Jose Lo 12/4/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /**
13 \class TXMLDocument
14 \ingroup IO
15 
16 TXMLDocument contains a pointer to an xmlDoc structure, after the
17 parser returns a tree built during the document analysis.
18 */
19 
20 #include "TXMLDocument.h"
21 #include "TXMLNode.h"
22 #include <libxml/tree.h>
23 
24 
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// TXMLDocument constructor.
29 
30 TXMLDocument::TXMLDocument(_xmlDoc *doc) : fXMLDoc(doc)
31 {
32  if (fXMLDoc) {
33  fRootNode = new TXMLNode(xmlDocGetRootElement(fXMLDoc));
34  } else {
35  fRootNode = 0;
36  }
37 }
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// TXMLDocument destructor.
41 /// Free the global variables that may
42 /// have been allocated by the parser.
43 
45 {
46  delete fRootNode;
47  xmlFreeDoc(fXMLDoc);
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Returns the root element node.
52 
54 {
55  return fRootNode;
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Returns the XML version string or 0 in case there is no document set.
60 
61 const char *TXMLDocument::Version() const
62 {
63  if (fXMLDoc)
64  return (const char *) fXMLDoc->version;
65  return 0;
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Returns external initial encoding, if any or 0 in case there is no
70 /// document set.
71 
72 const char *TXMLDocument::Encoding() const
73 {
74  if (fXMLDoc)
75  return (const char *) fXMLDoc->encoding;
76  return 0;
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Returns the URI for the document or 0 in case there is no document set.
81 
82 const char *TXMLDocument::URL() const
83 {
84  if (fXMLDoc)
85  return (const char *) fXMLDoc->URL;
86  return 0;
87 }
const char * Encoding() const
Returns external initial encoding, if any or 0 in case there is no document set.
TXMLNode * fRootNode
Definition: TXMLDocument.h:35
TXMLDocument(const TXMLDocument &)
virtual ~TXMLDocument()
TXMLDocument destructor.
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
Definition: TXMLDocument.h:28
const char * URL() const
Returns the URI for the document or 0 in case there is no document set.
const char * Version() const
Returns the XML version string or 0 in case there is no document set.
_xmlDoc * fXMLDoc
Definition: TXMLDocument.h:34
#define ClassImp(name)
Definition: Rtypes.h:279
TXMLNode * GetRootNode() const
Returns the root element node.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
Definition: TXMLNode.h:26