Open
Description
CCing issue above issue discovered from posting to stack overflow:
library(rvest)
library(dplyr)
test <- read_html_live("https://www.cdc.gov")
# single-quotes in xpath, no match:
html_elements(test, xpath = "//a[contains(text(),'Outbreaks')]")
#> {xml_nodeset (0)}
# swap quotes, " <-> '
html_elements(test, xpath = '//a[contains(text(), "Outbreaks")]')
#> {xml_nodeset (3)}
#> [1] <a href="https://www.cdc.gov/outbreaks/index.html">Outbreaks</a>
#> [2] <a href="https://www.cdc.gov/outbreaks/index.html" class="btn btn-outline ...
#> [3] <a href="https://www.cdc.gov/outbreaks/index.html" class="btn btn-outline ...
Perhaps a note about the needed single quotation starting order to an xpath could be added to the rvest documentation
Fyi
Metadata
Metadata
Assignees
Labels
No labels