checkLinks/checkLinks.R

checkLinks =
function(doc, local = TRUE)
{
  doc = htmlParse(doc)
  links = sapply(getNodeSet(doc, "//a[@href]"), xmlGetAttr, "href")
  if(local)
    links = grep("^(http|mailto)", links, invert = TRUE, value = TRUE)

  cur = getwd()
  on.exit(setwd(cur))
  setwd( dirname(docName(doc)))
  links[!file.exists(links)]
}

Try the XML package in your browser

Any scripts or data that you put into this service are public.

XML documentation built on July 16, 2018, 1:01 a.m.