Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
xmlreadfile.C File Reference

Detailed Description

Example to read and parse any xml file, supported by TXMLEngine class The input file, produced by xmlnewfile.C macro is used If you need full xml syntax support, use TXMLParser instead.

#include "TXMLEngine.h"
#include <cstdio>
{
// this function display all accessible information about xml node and its children
printf("%*c node: %s\n", level, ' ', xml.GetNodeName(node));
// display namespace
XMLNsPointer_t ns = xml.GetNS(node);
if (ns != nullptr)
printf("%*c namespace: %s refer: %s\n", level + 2, ' ', xml.GetNSName(ns), xml.GetNSReference(ns));
// display attributes
XMLAttrPointer_t attr = xml.GetFirstAttr(node);
while (attr != nullptr) {
printf("%*c attr: %s value: %s\n", level + 2, ' ', xml.GetAttrName(attr), xml.GetAttrValue(attr));
attr = xml.GetNextAttr(attr);
}
// display content (if exists)
const char *content = xml.GetNodeContent(node);
if (content != nullptr)
printf("%*c cont: %s\n", level + 2, ' ', content);
// display all child nodes
XMLNodePointer_t child = xml.GetChild(node);
while (child != nullptr) {
DisplayNode(xml, child, level + 2);
child = xml.GetNext(child);
}
}
void xmlreadfile(const char* filename = "example.xml")
{
// First create engine
// Now try to parse xml file
// Only file with restricted xml syntax are supported
if (!xmldoc) return;
// take access to main node
XMLNodePointer_t mainnode = xml.DocGetRootElement(xmldoc);
// display recursively all nodes and subnodes
// Release memory before exit
xml.FreeDoc(xmldoc);
}
int Int_t
Definition RtypesCore.h:45
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
void * XMLNodePointer_t
Definition TXMLEngine.h:17
void * XMLNsPointer_t
Definition TXMLEngine.h:18
void * XMLDocPointer_t
Definition TXMLEngine.h:20
void * XMLAttrPointer_t
Definition TXMLEngine.h:19
Author
Sergey Linev

Definition in file xmlreadfile.C.