[R] grep and XML
Simon Kiss
sjkiss at gmail.com
Mon Apr 16 23:03:54 CEST 2012
Hi all:
I struggle a lot scraping web data. I still haven't got a handle on the XML package.
I'd like to get particular exchange rates from this table:
https://raw.github.com/currencybot/open-exchange-rates/master/latest.json
This is the code that I'm working with:
library(RCurl)
library(XML)
txt<-getURL("https://raw.github.com/currencybot/open-exchange-rates/master/latest.json")
txt<-htmlParse(txt, asText=TRUE)
txt<- getNodeSet(txt, '//p')
So, I can get the node, properly but then, if I try soething like this:
grep(c('USD'), txt)
I get:
integer(0)
Can anyone suggest a way forward?
Yours, Simon KIss
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606
More information about the R-help
mailing list