Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
xmlmodifyfile.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_xml
3///
4/// Example to read, modify and store xml file, using TXMLEngine class
5/// The input file, produced by xmlnewfile.C macro is used
6/// If you need full xml syntax support, use TXMLParser instead
7///
8/// \macro_code
9///
10/// \author Sergey Linev
11
12#include "TXMLEngine.h"
13
14// scan node and returns number of childs
15// for each child create info node with name and number of childs
17{
18 int cnt = 0;
19 XMLNodePointer_t child = xml.GetChild(node);
20 while (child) {
21 cnt++;
22
23 int numsub = ScanNode(xml, child);
24
25 // create new <info> node
26 XMLNodePointer_t info = xml.NewChild(node, xml.GetNS(child), "info");
27
28 // set name and num attributes of info node
29 xml.NewAttr(info, nullptr, "name", xml.GetNodeName(child));
30 if (numsub > 0) xml.NewIntAttr(info, "num", numsub);
31
32 // move it after current node
33 xml.AddChildAfter(node, info, child);
34
35 // set pointer to new node
36 child = info;
37
38 xml.ShiftToNext(child);
39 }
40 return cnt;
41}
42
43void xmlmodifyfile(const char* filename = "example.xml")
44{
45 // First create engine
47
48 // Now try to parse xml file
50 if (xmldoc) {
51 // recursively scan all nodes, insert new when required
52 ScanNode(xml, xml.DocGetRootElement(xmldoc));
53
54 // Save document to file
55 xml.SaveDoc(xmldoc, "modify.xml");
56
57 // Release memory before exit
58 xml.FreeDoc(xmldoc);
59 }
60}
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
void * XMLNodePointer_t
Definition TXMLEngine.h:17
void * XMLDocPointer_t
Definition TXMLEngine.h:20
const char * cnt
Definition TXMLSetup.cxx:75