xmlAttrs {XML} | R Documentation

## Get the list of attributes of an XML node.

### Description

This returns a named character vector giving the name-value pairs of attributes of an XMLNode object which is part of an XML document.

### Usage

     xmlAttrs(node, ...)
     'xmlAttrs<-'(node, value,
                          suppressNamespaceWarning = getOption("suppressXMLNamespaceWarning", FALSE))

### Arguments

`node` | The `XMLNode` object whose attributes are to be extracted.
`...` | additional arguments for the specific methods, currently ignored but present for future extensions.
`value` | a named character vector giving the new attributes to be added to the node.
`suppressNamespaceWarning` | see `addChildren`

### Value

A named character vector, where the names are the attribute names and the elements are the corresponding values. This corresponds to the (attr<i>, "value<i>") pairs in the XML tag `<tag attr1="value1" attr2="value2"`

### Author(s)

Duncan Temple Lang

### References

http://www.w3.org

### See Also

`xmlChildren`, `xmlSize`, `xmlName`

### Examples

     fileName <- system.file("exampleData", "mtcars.xml", package="XML")
     doc <- xmlTreeParse(fileName)

     xmlAttrs(xmlRoot(doc))

     xmlAttrs(xmlRoot(doc)[["variables"]])

     doc <- xmlTreeParse(fileName, useInternalNodes = TRUE)
     d = xmlRoot(doc)
       # skip over the comment
     d = XML:::getSibling(d)

     xmlAttrs(d)
     xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
                      author = "Motor Trends")
     xmlAttrs(d)

       # clear all the attributes and then set new ones.
     removeAttributes(d)
     xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
                      author = "Motor Trends")

[Package XML version 1.94-0.1 Index]