xmlTreeParse {FastXML}R Documentation

Parses XML file into a tree.

Description

The xmlTreeParse function parses a file into a tree of XML nodes.

Usage

xmlTreeParse(filename)

Arguments

filename

Name of the file to parse.

Value

The value is opaqe (of class fxmlDoc) acts as a virtual list of nodes (of which there is usually just one). The only supported operations are subsetting operators to retrieve the root node (usually [[1]] or by name). For compatibility with the XML package $doc can be used to obtain a list with one named element which is the root node.

Nodes are opaque structures with the following virtual components:

$name name of the element

$children list of all entity child nodes.

$attributes string vector of all attributes

In addition, any other names are interpreted as an attempt to access a child node. When subsetting [[ all names are used directly to match the first child of that name/index.

Performance

To improve performence, especially repeated access, retrieved information (children, attributes, name) is also stored in the node. Repeated queries always yield exactly the same object. FastXML is strictly read-only and was designed for very fast retreival of information from XML documents. It is much faster than the XML package but does not offer any XML-authoring or other enhanced functionalities.

Examples

   doc <- xmlTreeParse(system.file("xml","test.xml",package="FastXML"))
   root <- doc[[1]]
   root$children
   root[['manufacturer']]
   root$table$attributes
   root$chair$price

[Package FastXML version 0.1-0 Index]