Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
16TXMLDocument contains a pointer to an xmlDoc structure, after the
17parser 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
30TXMLDocument::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
61const 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
72const 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
82const char *TXMLDocument::URL() const
83{
84 if (fXMLDoc)
85 return (const char *) fXMLDoc->URL;
86 return 0;
87}
#define ClassImp(name)
Definition Rtypes.h:364
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
const char * Encoding() const
Returns external initial encoding, if any or 0 in case there is no document set.
_xmlDoc * fXMLDoc
TXMLNode * GetRootNode() const
Returns the root element node.
const char * Version() const
Returns the XML version string or 0 in case there is no document set.
virtual ~TXMLDocument()
TXMLDocument destructor.
const char * URL() const
Returns the URI for the document or 0 in case there is no document set.
TXMLNode * fRootNode
TXMLDocument(const TXMLDocument &)=delete
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
Definition TXMLNode.h:20