test_that("xml_text returns only text without markup", { x <- read_xml("
This is some text. This is bold!
") expect_identical(xml_text(x), "This is some text. This is bold!") expect_identical(xml_text(xml_children(x)), "bold!") }) test_that("xml_text works properly with xml_nodeset objects", { x <- read_xml("Some text.
Some other.
No bold text
") children <- xml_children(x) x <- xml_find_first(children, ".//b|.//i") expect_identical( xml_text(x), c("text", "other", NA) ) }) test_that("xml_text<- and xml_set_text work properly with xml_nodeset objects", { x <- read_xml("Some text €
") expect_identical( xml_text(x), " Some text \u20ac \u00a0" ) expect_identical( xml_text(x, trim = TRUE), "Some text \u20ac" ) x2 <- read_html("Some text €
and more € text ")
expect_identical(
xml_text(xml_find_all(x2, ".//p"), trim = TRUE),
c("Some text \u20ac", "and more \u20ac text")
)
})
test_that("xml_integer() returns an integer vector", {
x <- read_xml("