An object of class XMLFlatTree which is specialized
to XMLFlatListTree
by the xmlFlatListTree
function and XMLHashTree
by the xmlHashTree
function.
Both objects are simply the environment which contains information
about the tree elements and functions to access this information. An xmlHashTree
object has an accessor method via
$
for accessing individual nodes within the tree.
One can use the node name/identifier in an expression such as
tt$myNode
to obtain the element.
The name of a node is either its XML node name or if that is already
present in the tree, a machine generated name.
One can find the names of all the nodes using the
objects
function since these trees are regular
environments in R.
Using the all = TRUE
argument, one can also find the
hidden elements that make define the tree's structure.
These are .children
and .parents
.
The former is an (hashed) environment. Each element is identified by the
node in the tree by the node's identifier (corresponding to the
name of the node in the tree's environment).
The value of that element is simply a character vector giving the
identifiers of all of the children of that node.
The .parents
element is also an environemnt.
Each element in this gives the pair of node and parent identifiers
with the parent identifier being the value of the variable in the
environment. In other words, we look up the parent of a node
named 'kid' by retrieving the value of the variable 'kid' in the
.parents
environment of this hash tree.
The function .addNode
is used to insert a new node into the
tree.
The structure of this tree allows one to easily travers all nodes,
navigate up the tree from a node via its parent. Certain tasks are
more complex as the hierarchy is not implicit within a node.