Learn R Programming

XiMpLe (version 0.11-3)

XMLName: Getter/setter methods for S4 objects of XiMpLe XML classes

Description

Used to get/set certain slots from objects of class XiMpLe_doc and XiMpLe_node.

Usage

XMLName(obj)

# S4 method for XiMpLe_node XMLName(obj)

XMLName(obj) <- value

# S4 method for XiMpLe_node XMLName(obj) <- value

XMLAttrs(obj)

# S4 method for XiMpLe_node XMLAttrs(obj)

XMLAttrs(obj) <- value

# S4 method for XiMpLe_node XMLAttrs(obj) <- value

XMLChildren(obj)

# S4 method for XiMpLe_node XMLChildren(obj)

# S4 method for XiMpLe_doc XMLChildren(obj)

XMLChildren(obj) <- value

# S4 method for XiMpLe_node XMLChildren(obj) <- value

# S4 method for XiMpLe_doc XMLChildren(obj) <- value

XMLValue(obj)

# S4 method for XiMpLe_node XMLValue(obj)

XMLValue(obj) <- value

# S4 method for XiMpLe_node XMLValue(obj) <- value

XMLFile(obj)

# S4 method for XiMpLe_doc XMLFile(obj)

XMLFile(obj) <- value

# S4 method for XiMpLe_doc XMLFile(obj) <- value

XMLDecl(obj)

# S4 method for XiMpLe_doc XMLDecl(obj)

XMLDecl(obj) <- value

# S4 method for XiMpLe_doc XMLDecl(obj) <- value

XMLDTD(obj)

# S4 method for XiMpLe_doc XMLDTD(obj)

XMLDTD(obj) <- value

# S4 method for XiMpLe_doc XMLDTD(obj) <- value

XMLScan(obj, name, as.list = FALSE)

# S4 method for XiMpLe_node XMLScan(obj, name, as.list = FALSE)

# S4 method for XiMpLe_doc XMLScan(obj, name, as.list = FALSE)

XMLScan(obj, name) <- value

# S4 method for XiMpLe_node XMLScan(obj, name) <- value

# S4 method for XiMpLe_doc XMLScan(obj, name) <- value

XMLScanDeep(obj, find = NULL, search = "attributes")

# S4 method for XiMpLe_node XMLScanDeep(obj, find = NULL, search = "attributes")

# S4 method for XiMpLe_doc XMLScanDeep(obj, find = NULL, search = "attributes")

Arguments

obj

An object of class XiMpLe_node or XiMpLe_doc

value

The new value to set.

name

Character, name of nodes to scan for.

as.list

Logical, if TRUE allways returns a list (or NULL), otherwise if exactly one result is found, it will be returned as as single XiMpLe_node.

find

Character, name of element to scan for.

search

Character, name of the slot to scan, one of "attributes", "name", or "value" for nodes.

Details

These are convenience methods to get or set slots from XML objects without using the @ operator.

XMLName():

get/set the XML node name (slot name of class XiMpLe_node)

XMLAttrs():

get/set the XML node attributes (slot attrs of class XiMpLe_node)

XMLValue():

get/set the XML node value (slot value of class XiMpLe_node)

XMLChildren():

get/set the XML child nodes (slot children of both classes XiMpLe_node and XiMpLe_doc)

XMLFile():

get/set the XML document file name (slot file of class XiMpLe_doc)

XMLDecl():

get/set the XML document declaration (slot xml of class XiMpLe_doc)

XMLDTD():

get/set the XML document doctype definition (slot dtd of class XiMpLe_doc)

Another special method can scan a node/document tree object for appearances of nodes with a particular name:

XMLScan(obj, name, as.list=FALSE):

get/set the XML nodes by name (recursively searches slot name of both classes XiMpLe_node and XiMpLe_doc). If as.list=TRUE allways returns a list (or NULL), otherwise if exactly one result is found, it will be returned as as single XiMpLe_node.

Finally, there is a method to scan for certain values in XiMpLe objects and just list them. For instance, it can be used to list all instances of a certain attribute type in a document tree:

XMLScanDeep(obj, find, search="attributes"):

returns all found instances of find in all slots defined by search.

See Also

node, XiMpLe_doc, XiMpLe_node

Examples

Run this code
xmlTestNode <- XMLNode("foo", XMLNode("testchild"))
XMLName(xmlTestNode) # returns "foo"
XMLName(xmlTestNode) <- "bar"
XMLName(xmlTestNode) # now returns "bar"

# search for a child node
XMLScan(xmlTestNode, "testchild")
# remove nodes of that name
XMLScan(xmlTestNode, "testchild") <- NULL

Run the code above in your browser using DataLab