xmlValue

0th

Percentile

Extract or set the contents of a leaf XML node

Some 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.

Keywords
file
Usage
xmlValue(x, ignoreComments = FALSE, recursive = TRUE,
          encoding = getEncoding(x), trim = FALSE)
Arguments
x

the XMLNode object whose contents are to be returned.

ignoreComments

a logical value which, if TRUE does not include the text in XML comment nodes. If this is FALSE, 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 node x.

encoding

experimental functionality and parameter related to encoding.

trim

a logical value controlling whether we remove leading or trailing white space when returning the string value

Value

The object stored in the value slot of the XMLNode object. This is typically a string.

References

http://www.w3.org/XML, http://www.jclark.com/xml, http://www.omegahat.net

See Also

xmlChildren xmlName xmlAttrs xmlNamespace

Aliases
  • xmlValue
  • xmlValue.XMLCDataNode
  • xmlValue.XMLNode
  • xmlValue.XMLProcessingInstruction
  • xmlValue.XMLTextNode
  • xmlValue.XMLComment
  • xmlValue<-
  • xmlValue<-,XMLAbstractNode-method
  • xmlValue<-,XMLInternalTextNode-method
  • xmlValue<-,XMLTextNode-method
  • coerce,XMLInternalTextNode,character-method
Examples
# NOT RUN {
 node <- xmlNode("foo", "Some text")
 xmlValue(node)

 xmlValue(xmlTextNode("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
# }
Documentation reproduced from package XML, version 3.98-1.19, License: BSD_2_clause + file LICENSE

Community examples

vanessa.bigotjuloux@icloud.com at Jul 26, 2018 XML v3.98-1.12

``` characters <- cbind( "names" = lapply(getNodeSet(doc, "//ns:persName[@xml:id][text()]", ns), function(x) xmlValue(x)) ) #display the result in a list, with the column entitled "names" characters ``` Explanation: Get the text value `x` in each node (of the variable `doc` ) `persName[@xml:id]`, where `x`= `text()` according to namespace `ns` definition from `TEI` [guidelines](http://www.tei-c.org/ns/1.0/) `function(x)` is required since the function `xmlValue` is not predefined in R