Learn R Programming

XML (version 3.1-1)

xmlName: Extraces the tag name of an XMLNode object.

Description

Each XMLNode object has an element or tag name introduced in the entry in an XML document. This function returns that name.

We can also set that name using xmlName(node) <- "name" and the value can have an XML name space prefix, e.g. "r:name".

Usage

xmlName(node, full = FALSE)

Arguments

Value

  • A character vector of length 1 which is the node$name entry.

References

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

See Also

xmlChildren, xmlAttrs, xmlTreeParse

Examples

Run this code
fileName <- system.file("exampleData", "test.xml", package="XML") 
 doc <- xmlTreeParse(fileName)
 xmlName(xmlRoot(doc)[[1]])

 tt = xmlRoot(doc)[[1]]
 xmlName(tt)
 xmlName(tt) <- "bob"


  # We can set the node on an internal object also.
 n = newXMLNode("x")

 xmlName(n)
 xmlName(n) <- "y"

 
 xmlName(n) <- "r:y"

Run the code above in your browser using DataLab