tests/testthat/test-comment.R

context("comment")

test_that("Comment creation works", {
  x <- xml_new_root("root")
  xml_add_child(x, xml_comment("Hello!"))
  expect_identical("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><!--Hello!--></root>\n", as.character(x, options = ""))
})

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.