Today we are pleased to release version 1.1.1 of xml2. xml2 makes it easy to read, create, and modify XML with R. You can install it with:
As well as fixing many bugs, this release:
xml2 has been overhauled with a set of methods to make generating and modfying XML easier:
xml_new_root() can be used to create a new document and root node simultaneously.
xml_add_parent() makes it easy to insert a node as the parent of an existing node.
xml2 1.1.1 improves support for converting to and from R lists, thanks in part to work by Peter Foley and Jenny Bryan. In particular xml2 now supports preserving the root node name as well as saving all xml2 attributes as R attributes. These changes allows you to convert most XML documents to and from R lists with
as_xml_document() without loss of data.
doc <- read_xml(system.file("extdata/order-doc.xml", package = "xml2")) schema <- read_xml(system.file("extdata/order-schema.xml", package = "xml2")) xml_validate(doc, schema) #>  TRUE #> attr(,"errors") #> character(0)
Jeroen also released the first xml2 extension package in conjunction with xml2 1.1.1, xslt. xslt allows one to apply XSLT (Extensible Stylesheet Language Transformations) to XML documents, which are great for transforming XML data into other formats such as HTML.