ROOT implementation of a XML DOM Parser
This is an example of how Dom Parser walks the DOM tree recursively. This example will parse any xml file.
To run this program
Requires: person.xml
PersonList:
Comment:
This is an example...
Person: ID:1
FirstName: Alicia
LastName: Smith
Gender: F
DateOfBirth:
Day: 13
Month: 10
Year: 1978
Address:
Street: Grand Avenue, 143
PostalCode: Toronto 2283
Country: Canada
Person: ID:2
FirstName: Maria
LastName: White
Gender: F
DateOfBirth:
Day: 29
Month: 5
Year: 1980
Address:
Street: Green Land Park, 143
PostalCode: Vancouver BC V6C 2C2
Country: Canada
{
}
}
}
}
}
}
}
void DOMRecursive()
{
ParseContext(node);
}
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
virtual Int_t ParseFile(const char *filename)
Parse the XML file where filename is the XML file name.
TXMLAttribute is the attribute of an Element.
const char * GetValue() const
const char * GetName() const
Returns name of object.
TXMLNode * GetRootNode() const
Returns the root element node.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
const char * GetContent() const
Returns the content if any, or 0.
TXMLNode * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
const char * GetNodeName() const
Returns the node's name.
Bool_t HasAttributes() const
Returns true if Element node has attribute.
EXMLElementType GetNodeType() const
Returns the node's type.
void SetValidate(Bool_t val=kTRUE)
The parser will validate the xml file if val = true.
- Author
- Sergey Linev
Definition in file DOMRecursive.C.