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

Description Usage Arguments Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
node(
  obj,
  node = list(),
  what = NULL,
  cond.attr = NULL,
  cond.value = NULL,
  element = NULL
)

## S4 method for signature '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 replacement method for signature '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

1
2
3
4
5
## Not run: 
node(my.xml.tree, node=list("html","body"), what="attributes")
node(my.xml.tree, node=list("html","head","title"), what="value") <- "foobar"

## End(Not run)

XiMpLe documentation built on Sept. 20, 2020, 1:07 a.m.