XML (version 3.1-1)

xmlRoot: Get the top-level XML node.

Description

These are a collection of methods for providing easy access to the top-level XMLNode object resulting from parsing an XML document. They simplify accessing this node in the presence of auxillary information such as DTDs, file name and version information that is returned as part of the parsing.

Usage

xmlRoot(x, skip = TRUE, ...)
## S3 method for class 'XMLDocumentContent':
xmlRoot(x, skip = TRUE, ...)
## S3 method for class 'XMLInternalDocument':
xmlRoot(x, skip = TRUE, ...)
## S3 method for class 'HTMLDocument':
xmlRoot(x, skip = TRUE, ...)

Arguments

Value

  • An object of class XMLNode.

References

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

See Also

xmlTreeParse [[.XMLNode

Examples

Run this code
doc <- xmlTreeParse(system.file("exampleData", "mtcars.xml", package="XML"))
  xmlRoot(doc)
   # Note that we cannot use getSibling () on a regular R-level XMLNode object
   # since we cannot go back up or across the tree from that node, but
   # only down to the children.

    # Using an internal node via xmlParse (== xmlInternalTreeParse())
  doc <- xmlParse(system.file("exampleData", "mtcars.xml", package="XML"))
  n = xmlRoot(doc, skip = FALSE)
     # skip over the DTD and the comment
  d = getSibling(getSibling(n))

Run the code above in your browser using DataLab