Closed tomck closed 7 years ago
Thanks for the report @tomck ,
retmode
and rettype
are both valid eutils arguments, I don't think the rentrez docs discuss the difference, which might be a useful thing to do.
For this use case, it's very hard to make this an "automatic" part on entrez_summary
because there is no indication which fields from which databases are going to have these XML-ish entries. And the XML itself is hard to parse cleanly.
On the other hand, we could either document a workaround or provide a function to handle thise.
I'll think about that, in the mean time, in this specific case I think the escaped XML is actually what get's returned by efetch. So you could do this to get the results you are interested in:
cp460 <- entrez_fetch(db="biosample", id=2886856, rettype="xml", parsed=TRUE)
lat <- XML::xmlValue(cp460[["//Attribute[@attribute_name='latitude']"]])
lon <- XML::xmlValue(cp460[["//Attribute[@attribute_name='longitude']"]])
c(lat, lon)
[1] "40.79108" "-73.96178"
After a mere ... year, i have at last provided a little documentation page on how to deal with these records. https://github.com/ropensci/rentrez/wiki/Parse-html--information-within-esummary-records
Closing now
Above is a testcase, below is how it looks direct: http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=biosample&id=2886856&version=2.0&retmode=json
(very confusing that for eutils it's retmode but rentrez it's rettype, but I digress)
Expected results: ability to take things like cp460$sampledata$latitude and cp460$sampledata$longitude Actual results: XML as escaped text