Learn R Programming

XiMpLe (version 0.11-3)

node: Extract/manipulate a node or parts of it from an XML tree

Description

This method can be used to get parts of a parsed XML tree object, or to fill it with new values.

XiMpLe.XML is a class union for objects of classes XiMpLe_node and XiMpLe_doc.

Usage

node(
  obj,
  node = list(),
  what = NULL,
  cond.attr = NULL,
  cond.value = NULL,
  element = NULL
)

# S4 method for XiMpLe.XML node( obj, node = list(), what = NULL, cond.attr = NULL, cond.value = NULL, element = NULL )

node( obj, node = list(), what = NULL, cond.attr = NULL, cond.value = NULL, element = NULL ) <- value

# S4 method for XiMpLe.XML node( obj, node = list(), what = NULL, cond.attr = NULL, cond.value = NULL, element = NULL ) <- value

Arguments

obj

An object of class XiMpLe_doc or XiMpLe_node.

node

A list of node names (or their numeric values), where each element is the child of its previous element. duplicate matches will be returned as a list.

what

A character string, must be a valid slot name of class XiMpLe_node, like "attributes" or "value". If not NULL, only that part of a node will be returned. There's also two special properties for this option: what="@path" will not return the node or it's contents, but a character string with the "path" to it in the object; what="obj@path" is the same but won't have obj substituted with the object's name.

cond.attr

A named character string, to further filter the returned results. If not NULL, only nodes with fully matching attributes will be considered.

cond.value

A character string, similar to cond.attr, but is matched against the value between a pair of tags.

element

A character string naming one list element of the node slot. If NULL, all elements will be returned.

value

The value to set.

Examples

Run this code
if (FALSE) {
node(my.xml.tree, node=list("html","body"), what="attributes")
node(my.xml.tree, node=list("html","head","title"), what="value") <- "foobar"
}

Run the code above in your browser using DataLab