getNodeSet {XML} | R Documentation

## Find matching nodes in an internal XML tree/DOM

### Description

This function provides a way to find XML nodes that match a particular criterion. It uses the XPath syntax and allows quite powerful expressions for identifying nodes. The XPath language requires some knowledge, but tutorials are available.

### Usage

    getNodeSet(doc, path)

### Arguments

`doc` | an object of class `XMLInternalDocument`
`path` | a string (character vector of length 1) giving the XPath expression to evaluate.

### Details

This calls the libxml routine `xmlXPathEval`.

### Value

The results can currently be different based on the returned value from the XPath expression evaluation:

`list` | a node set
`numeric` | a number
`logical` | a boolean
`character` | a string, i.e. a single character element.

### Note

More of the XPath functionality provided by libxml can and may be made available to the R package. Facilities such as compiled XPath expressions, functions, ordered node information,

Please send requests to the maintainer.

### Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

### References

http://xmlsoft.org, http://www.w3.org/xml http://www.w3.org/TR/xpath http://www.omegahat.org/RSXML

### See Also

`xmlTreeParse` with `useInternalNodes` as `TRUE`.

### Examples

     doc = xmlTreeParse(system.file("exampleData", "tagnames.xml", package = "XML"), useInternalNodes = TRUE)
     getNodeSet(doc, "/doc//b[@status]")
     getNodeSet(doc, "/doc//b[@status='foo']")

     els = getNodeSet(doc, "/doc//a[@status]")
     sapply(els, function(el) xmlGetAttr(el, "status"))

[Package XML version 0.99-1 Index]