Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (78 sloc) 2.94 KB
title: xml2 1.1.1
```{r setup, include=FALSE}
collapse = TRUE,
comment = "#>"
<meta charset="utf-8">
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:
```{r, eval = FALSE}
As well as fixing many bugs, this release:
* Makes it easier to create an modify XML
* Improves roundtrip support between XML and lists
* Adds support for XML validation and XSLT transformations.
You can see a full list of changes in the [release notes]( This is the first release maintained by [Jim Hester](
## Creating and modifying XML
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
xml_new_root("x") %>%
xml_add_child("y") %>%
* New `xml_set_text()`, `xml_set_name()`, `xml_set_attr()`, and
`xml_set_attrs()` make it easy to modify nodes within a pipeline.
x <- read_xml("<a>
<b />
x %>%
xml_find_all(".//b") %>%
xml_set_name("banana") %>%
xml_set_attr("oldname", "b")
* New `xml_add_parent()` makes it easy to insert a node as the parent of
an existing node.
* You can create more esoteric node types with `xml_comment()` (comments),
`xml_cdata()` (CDATA nodes), and `xml_dtd()` (DTDs).
## Coercion to and from R Lists
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_list()`
and `as_xml_document()` without loss of data.
x <- read_xml("<fruits><apple color = 'red' /></fruits>")
## XML validation and xslt
xml2 1.1.1 also adds support for XML validation, thanks to [Jeroen
Simply read the document and schema files and call `xml_validate()`.
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)
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.
You can’t perform that action at this time.