TXMLDocument.cxx

Go to the documentation of this file.
00001 // @(#)root/xmlparser:$Id: TXMLDocument.cxx 28833 2009-06-05 14:08:12Z rdm $
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 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TXMLDocument                                                         //
00015 //                                                                      //
00016 // TXMLDocument contains a pointer to an xmlDoc structure, after the    //
00017 // parser returns a tree built during the document analysis.            //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 
00021 #include "TXMLDocument.h"
00022 #include "TXMLNode.h"
00023 #include <libxml/tree.h>
00024 
00025 
00026 ClassImp(TXMLDocument);
00027 
00028 //______________________________________________________________________________
00029 TXMLDocument::TXMLDocument(_xmlDoc *doc) : fXMLDoc(doc)
00030 {
00031    // TXMLDocument constructor.
00032 
00033    if (fXMLDoc) {
00034       fRootNode = new TXMLNode(xmlDocGetRootElement(fXMLDoc));
00035    } else {
00036       fRootNode = 0;
00037    }
00038 }
00039 
00040 //______________________________________________________________________________
00041 TXMLDocument::~TXMLDocument()
00042 {
00043    // TXMLDocument destructor.
00044    // Free the global variables that may
00045    // have been allocated by the parser.
00046 
00047    delete fRootNode;
00048    xmlFreeDoc(fXMLDoc);
00049 }
00050 
00051 //______________________________________________________________________________
00052 TXMLNode *TXMLDocument::GetRootNode() const
00053 {
00054    // Returns the root element node.
00055 
00056    return fRootNode;
00057 }
00058 
00059 //______________________________________________________________________________
00060 const char *TXMLDocument::Version() const
00061 {
00062    // Returns the XML version string or 0 in case there is no document set.
00063 
00064    if (fXMLDoc)
00065       return (const char *) fXMLDoc->version;
00066    return 0;
00067 }
00068 
00069 //______________________________________________________________________________
00070 const char *TXMLDocument::Encoding() const
00071 {
00072    // Returns external initial encoding, if any or 0 in case there is no
00073    // document set.
00074 
00075    if (fXMLDoc)
00076       return (const char *) fXMLDoc->encoding;
00077    return 0;
00078 }
00079 
00080 //______________________________________________________________________________
00081 const char *TXMLDocument::URL() const
00082 {
00083    // Returns the URI for the document or 0 in case there is no document set.
00084 
00085    if (fXMLDoc)
00086       return (const char *) fXMLDoc->URL;
00087    return 0;
00088 }

Generated on Tue Jul 5 14:30:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1