tests/testthat/test-cdata.R

context("cdata")

test_that("CDATA creation works", {
  x <- xml_new_root("root")
  xml_add_child(x, xml_cdata("<d/>"))
  expect_identical(as.character(x),  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><![CDATA[<d/>]]></root>\n")
})

Try the xml2 package in your browser

Any scripts or data that you put into this service are public.

xml2 documentation built on July 9, 2023, 6:44 p.m.