XML package example code?
Cls59 is correct that there is a lot of example code, just look in ? htmlTreeParse and you'll get most of what you need i think. here's some simplified code I use a lot of (XPath expressions are used to parse the code): # libraries library(RCurl) library(XML) # google url my.url <- "http://www.google.co.uk/search?hl=en&client=firefox- a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=6Sd&q=google +wave&btnG=Search&meta=&aq=f&oq=" # download page html <- getURL(my.url) html.tree <- htmlTreeParse(html, useInternalNodes = TRUE, error = function(...){}) # the xpath expression is next nodes <- getNodeSet(html.tree, "//a[@href][@class='l']") links <- sapply(nodes, function(x) x <- xmlAttrs(x)[[1]]) HTH Tony
On 25 Nov, 01:49, Peng Yu <pengyu... at gmail.com> wrote:
I'm interested in parsing an html page. I should use XML, right? Could you somebody show me some example code? Is there a tutorial for this package?
______________________________________________ R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.