Re: [R] extracting a value from XML

2015-09-21 Thread Glenn Schultz
Hi Bob, Thanks, can you help me undestand why it starts with //observation and how you know that it is a node? Glenn On Sep 21, 2015, at 01:56 PM, boB Rudis wrote: This is how (one way) in both the xml2 package and XML package: library(xml2) library(XML) txt <- ' ' doc <- read_xml(txt)

Re: [R] extracting a value from XML

2015-09-21 Thread boB Rudis
The " > 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="10"> > date="2015-09-01" value="0.46"/> > ' > > doc <- read_xml(txt) > xml_attr(xml_find_all(doc, "//o

Re: [R] extracting a value from XML

2015-09-21 Thread boB Rudis
This is how (one way) in both the xml2 package and XML package: library(xml2) library(XML) txt <- ' ' 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,

[R] extracting a value from XML

2015-09-21 Thread Glenn Schultz
Hi All, I have been trying to extract a value from XML.  I have been at it for several days off and on and I can't seem to get my head around the problem.   I basically understand the examples in R help but I cannot replicate success with the below  I tried to use xmlValue(doc, "//[[value]]")