The (tag) name of an xml element.
Modify the (tag) name of an element
Arguments
- x
A document, node, or node set.
- ns
Optionally, a named vector giving prefix-url pairs, as produced by
xml_ns()
. If provided, all names will be explicitly qualified with the ns prefix, i.e. if the elementbar
is defined in namespacefoo
, it will be calledfoo:bar
. (And similarly for attributes). Default namespaces must be given an explicit name. The ns is ignored when usingxml_name<-()
andxml_set_name()
.- value
a character vector with replacement name.
Examples
x <- read_xml("<bar>123</bar>")
xml_name(x)
#> [1] "bar"
y <- read_xml("<bar><baz>1</baz>abc<foo /></bar>")
z <- xml_children(y)
xml_name(xml_children(y))
#> [1] "baz" "foo"