Set the name space on a node
setXMLNamespace.RdThis function sets the name space for an XML node, typically an internal node. We can use it to either define a new namespace and use that, or refer to a name space definition in an ancestor of the current node.
Arguments
- node
the node on which the name space is to be set
- namespace
the name space to use for the node. This can be a name space prefix (string) defined in an ancestor node, or a named character vector of the form
c(prefix = URI)that defines a new namespace on this node, or we can use a name space object created withnewXMLNamespace.- append
currently ignored.
Value
An object of class XMLNamespaceRef which is a reference to the
native/internal/C-level name space object.
Examples
# define a new namespace
e = newXMLNode("foo")
setXMLNamespace(e, c("r" = "http://www.r-project.org"))
#> <pointer: 0x5ee8470a64f0>
#> attr(,"class")
#> [1] "XMLNamespaceRef"
# use an existing namespace on an ancestor node
e = newXMLNode("top", namespaceDefinitions = c("r" = "http://www.r-project.org"))
setXMLNamespace(e, "r")
#> <pointer: 0x5ee84e2da700>
#> attr(,"class")
#> [1] "XMLNamespaceRef"
e
#> <r:top xmlns:r="http://www.r-project.org"/>