This is how (one way) in both the xml2 package and XML package:
library(xml2)
library(XML)
txt <- '<?xml version="1.0" encoding="utf-8"?>
<observations realtime_start="2015-09-21"
realtime_end="2015-09-21"
observation_start="2015-09-01" observation_end="2015-09-01"
units="lin" output_type="1" file_type="xml"
order_by="observation_date" sort_order="asc"
count="1" offset="0"
limit="100000">
<observation realtime_start="2015-09-21"
realtime_end="2015-09-21"
date="2015-09-01" value="0.46"/>
</observations>'
doc <- read_xml(txt)
xml_attr(xml_find_all(doc, "//observation"), "value")
doc1 <- xmlParse(txt)
xpathSApply(doc1, "//observation", xmlGetAttr, "value")
On Mon, Sep 21, 2015 at 2:01 PM, Glenn Schultz <glennmschultz at me.com>
wrote:> <?xml version="1.0" encoding="utf-8"?>
> <observations realtime_start="2015-09-21"
realtime_end="2015-09-21"
> observation_start="2015-09-01"
observation_end="2015-09-01" units="lin"
> output_type="1" file_type="xml"
order_by="observation_date" sort_order="asc"
> count="1" offset="0" limit="100000">
> <observation realtime_start="2015-09-21"
realtime_end="2015-09-21"
> date="2015-09-01" value="0.46"/>
> </observations>