Learn R Programming

XML (version 0.7-3)

xmlNamespace: Retrieve the namespace value of an XML node.

Description

Each XML node has a namespace identifier which is a string indicating in which DTD (Document Type Definition) the definition of that element can be found. This avoids the problem of having different document definitions using the same names for XML elements that have different meaning. To resolve the name space, i.e. i.e. find out to where the identifier points, one can use the expression xmlNamespace(xmlRoot(doc)).

Usage

xmlNamespace(x)

Arguments

x
the object whose namespace is to be computed

Value

  • For non-root nodes, this returns a string giving the identifier of the name space for this node. For the root node, this returns a list with $3$ elements:
  • idthe identifier by which other nodes refer to this namespace.
  • urithe URI or location that defines this namespace.
  • local? (can't remember off-hand).

References

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

See Also

xmlName xmlChildren xmlAttrs xmlValue

Examples

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

  node <- xmlNode("arg", xmlNode("name", "foo"), namespace="R")
  xmlNamespace(node)

Run the code above in your browser using DataLab