XML isn't as easy to deal with as it should be in R. Although there is an XML package, it is not straightforward to use, and worse, XML files rarely play nice with it either.
In reality, then, there are a variety of ways to handle XML files depending on the problems they represent. This page documents those I've come across so far.
First, install XML
: install.packages('XML')
and then library(XML)
.
If you need XML files to play with, here are some suggestions:
- Food inspection ratings data can be found in XML on the Food Standards Agency inspections API.
A tutorial on using the package to grab an XML file can be found on R-Bloggers here
This will work if the XML file is nicely formatted. If not...
These solutions come from Stack Overflow