xmlFlatListTree {XML}R Documentation

Constructors for trees stored as flat list of nodes with information about parents and children

Description

These (and related internal) functions allow us to represent trees as a simple, non-hierarchical collection of nodes along with corresponding tables that identify the parent and child relationships. This is different from representing a tree as a list of lists of lists ... in which each node has a list of its own children. In a functional language like R, it is not possible then for the children to be able to identify their parents.

We use an environment to represent these flat trees. Since these are mutable without requiring the change to be reassigned, we can modify a part of the tree locally without having to reassign the top-level object.

We can use either a list (with names) to store the nodes or a hash table/associative array that uses names. There is a non-trivial performance difference.

Usage

xmlHashTree(nodes = list(), parents = character(), children = list(), 
             env = new.env(TRUE))
xmlFlatListTree(nodes = list(), parents = character(), children = list(), env = new.env(), n = 200)

Arguments

nodes a collection of existing nodes that are to be added to the tree. These are used to initialize the tree. If this is specified, you must also specify children and parents.
parents the parent relationships for the nodes given by nodes.
children the children relationships for the nodes given by nodes.
env an environment in which the information for the tree will be stored. This is essentially the tree object as it allows us to modify parts of the tree without having to reassign the top-level object. Unlike most R data types, environments are mutable.
n for xmlFlatListTree, this is used as the default size to allocate for the list containing the nodes

Details

Value

An object of class XMLFlatTree which is specialized to XMLFlatListTree by the xmlFlatListTree function and XMLHashTree by the xmlHasTree function. Both are simply the environment.

Author(s)

Duncan Temple Lang

References

http://www.w3.org/XML

See Also

xmlTreeParse xmlTree xmlOutputBuffer xmlOutputDOM

Examples



[Package XML version 0.99-8 Index]