File: test-xml_type.R

package info (click to toggle)
r-cran-xml2 1.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 976 kB
  • sloc: cpp: 1,828; xml: 333; javascript: 238; ansic: 213; sh: 74; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
test_that("xml_type() works", {
  x <- read_xml(
    "<body>
    <p>Some <b>text</b>.</p>
    <p>Some <i>other</i>.</p>
    <p>No bold text</p>
    </body>"
  )

  children <- xml_children(x)
  x <- xml_find_first(children, ".//b|.//i")

  expect_equal(xml_type(x[[1]]), "element")
  expect_equal(xml_type(x[[3]]), NA_character_)

  expect_equal(xml_type(x), c("element", "element", NA))

  empty <- xml_children(x)
  expect_identical(xml_type(empty), character())
})