xml2 icon indicating copy to clipboard operation
xml2 copied to clipboard

`as_html()`/`as_xml()`

Open hadley opened this issue 2 years ago • 1 comments

Useful way to create nodes from strings

as_html <- function(x) {
  xml2::xml_contents(xml2::xml_contents(xml2::read_html(x)))[[1]]
}
as_xml <- function(x) {
  xml2::xml_contents(xml2::read_xml(x))[[1]]
}

hadley avatar Oct 27 '21 12:10 hadley

Key challenge is with as_html() because it's nice to able to write as_html("<img>") and just get the img node back.

hadley avatar Oct 27 '21 13:10 hadley