25 Date() : day(0), month(0), year(0) { }
27 Int_t GetDay()
const {
return day; }
28 Int_t GetMonth()
const {
return month; }
29 Int_t GetYear()
const {
return year; }
30 void SetDay(
Int_t d) { day=
d; }
31 void SetMonth(
Int_t m) { month=
m;}
32 void SetYear(
Int_t y) { year=
y;}
43 street(s), postalCode(p), country(c) { }
44 TString GetStreet()
const {
return street; }
45 TString GetPostalCode()
const {
return postalCode; }
46 TString GetCountry()
const {
return country; }
47 void SetStreet(
const TString &s) { street = s; }
48 void SetPostalCode(
const TString &p) { postalCode = p; }
49 void SetCountry(
const TString &c) { country =
c; }
60 id(i), firstName(f), lastName(l), gender(g), dateOfBirth(d), address(a){ }
67 TString GetFirstName()
const {
return firstName; }
68 TString GetLastName()
const {
return lastName; }
69 Char_t GetGender()
const {
return gender; }
70 Date *GetDate()
const {
return dateOfBirth; }
71 Address *GetAddress()
const {
return address; }
72 Int_t GetID()
const {
return id; }
74 friend ostream &
operator << (ostream& out,
const Person& p) {
75 out <<
"ID: " << p.id << endl;
76 out <<
"First name: " << p.firstName << endl;
77 out <<
"Last name: " << p.lastName << endl;
78 out <<
"Sex: " << p.gender << endl;
79 out <<
"Date of birth: " << p.dateOfBirth->GetDay() <<
"/"
80 << p.dateOfBirth->GetMonth() <<
"/"
81 << p.dateOfBirth->GetYear() << endl;
82 out <<
"Address: " << p.address->GetStreet() << endl;
83 out <<
"\t" << p.address->GetPostalCode() << endl;
84 out <<
"\t" << p.address->GetCountry() << endl;
101 listOfPerson =
new TList();
115 ParsePersonList(node);
120 void ParsePersonList(
TXMLNode *node) {
130 if (strcmp(attr->
GetName(),
"ID") == 0) {
158 return new Date(d,
m,
y);
161 Address *ParseAddress(
TXMLNode *node) {
168 if (strcmp(node->
GetNodeName(),
"PostalCode") == 0) {
176 return new Address(s, p, c);
193 if (strcmp(node->
GetNodeName(),
"DateOfBirth") == 0)
200 return new Person(
id, firstName, lastName, gender, date, address);
203 friend ostream&
operator << (ostream& out,
const PersonList & pl) {
206 while ((p =(Person*)
next())){
215 while ((p =(Person*)
next())) {
221 Int_t numberOfPersons;
228 PersonList personlist;
229 gROOT->ProcessLine(
".O 0");
231 if (personlist.ParseFile(dir+
"/person.xml") == 0)
232 cout << personlist << endl;
const char * GetNodeName() const
Returns the node's name.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
TXMLNode * GetRootNode() const
Returns the root element node.
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
Bool_t HasAttributes() const
Returns true if Element node has attribute.
TXMLNode * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
virtual Int_t ParseFile(const char *filename)
Parse the XML file where filename is the XML file name.
R__EXTERN TSystem * gSystem
const char * GetParseCodeMessage(Int_t parseCode) const
Returns the parse code message.
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
TXMLAttribute is the attribute of an Element.
const char * GetValue() const
EXMLElementType GetNodeType() const
Returns the node's type.
Mother of all ROOT objects.
const char * GetText() const
Returns the content of a Text node if node is a TextNode, 0 otherwise.
const char * GetName() const
Returns name of object.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
ROOT::R::TRInterface & operator<<(ROOT::R::TRInterface &r, TString code)