0

I would like to use XPath to return a character vector of the link inside each anchor tag.

I can return the table of interest with

library(RCurl)
library(XML)
url <- "http://dps.alaska.gov/sorweb/aspx/sorcra1.aspx"
readHTMLTable(url, useInternalNodes = T)[[3]]

but I want to also return the link in each anchor tag associated with the name. This is what I have so far.

dat <- htmlTreeParse(url, useInternalNodes = T)
getNodeSet(dat, "///tr/td/a")

So my output is a list of RCurl objects instead of a desired character vector and I have included other tags besides the ones in my table with an imperfect XPath.

So my question is two parts. How do I convert the getNodeSet element outputs to characters vectors with the tag and what is an efficient method to get a desired XPath search?

4

1 に答える 1