R/pmc_xml.R

Defines functions pmc_xml

Documented in pmc_xml

#' Download XML from PubMed Central
#'
#' @param id a PMC id starting with 'PMC'
#'
#' @return \code{xml_document}
#'
#' @source \url{https://europepmc.org/RestfulWebService}
#'
#' @examples
#' \dontrun{
#' doc <- pmc_xml("PMC2231364")
#' }
#'
#' @export

pmc_xml <- function(id) {
  if (!grepl("^PMC[0-9]+$", id)) {
    stop("id should be a valid PMC id like PMC2231364")
  }
  url1 <- paste0(
    "https://www.ebi.ac.uk/europepmc/webservices/rest/", id, "/fullTextXML"
  )
  xml2::read_xml(url1)
}

Try the tidypmc package in your browser

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

tidypmc documentation built on Aug. 1, 2019, 5:05 p.m.