xml2 icon indicating copy to clipboard operation
xml2 copied to clipboard

xml_find_lgl() should automatically coerce output to boolean

Open hadley opened this issue 2 years ago • 1 comments

library(xml2)
library(magrittr)

xml <- read_xml("<body><a><b></b><b></b></a><a></a></body>")
xml %>% 
  xml_find_all(".//a") %>% 
  xml_find_lgl("./b")
#> Error: result of type: 'list', not logical

xml %>% 
  xml_find_all(".//a") %>% 
  xml_find_lgl("boolean(./b)")
#> [1]  TRUE FALSE

Created on 2021-10-27 by the reprex package (v2.0.1)

Similarly for xml_find_chr(), xml_find_int() etc.

hadley avatar Oct 27 '21 12:10 hadley

yeah, probably makes sense

jimhester avatar Oct 27 '21 14:10 jimhester