xml2
xml2 copied to clipboard
`as_html()`/`as_xml()`
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]]
}
Key challenge is with as_html()
because it's nice to able to write as_html("<img>")
and just get the img
node back.