Extract or set the contents of a leaf XML node
xmlValue.RdSome types of XML nodes have no children nodes, but are leaf nodes and
simply contain text. Examples are XMLTextMode, XMLProcessingInstruction.
This function provides access to their raw contents.
This has been extended to operate recursivel on arbitrary XML nodes
that contain a single text node.
Usage
xmlValue(x, ignoreComments = FALSE, recursive = TRUE,
encoding = getEncoding(x), trim = FALSE)Arguments
- x
the
XMLNodeobject whose contents are to be returned.- ignoreComments
a logical value which, if
TRUEdoes not include the text in XML comment nodes. If this isFALSE, the text in the comments is part of the return value.- recursive
a logical value indicating whether to process all sub-nodes (
TRUE) or only the text nodes within the nodex.
Examples
node <- xmlNode("foo", "Some text")
xmlValue(node)
#> [1] "Some text"
xmlValue(xmlTextNode("some more raw text"))
#> [1] "some more raw text"
# Setting the xmlValue().
a = newXMLNode("a")
xmlValue(a) = "the text"
xmlValue(a) = "different text"
a = newXMLNode("x", "bob")
xmlValue(a) = "joe"
b = xmlNode("bob")
xmlValue(b) = "Foo"
xmlValue(b) = "again"
b = newXMLNode("bob", "some text")
xmlValue(b[[1]]) = "change"
b
#> <bob>change</bob>