5.3 XML data

The XML standard has been in general use since 1998, but it isn’t used for serving web resources anywhere near as widely as it once was. Nevertheless, occasionally you’ll come across web resources or other data in XML format.

Navigating XML data structures can be a bit hairy and is worthy of a workshop of its own. We recommend the xml2 package for working with XML, which can also load data directly from URLs using the read_xml() function.

The example below loads data from the Queensland Government’s Air Quality Monitoring Live data feed.

airqual_xml <- xml2::read_xml("https://apps.des.qld.gov.au/air-quality/xml/feed.php?category=1&region=ALL")

airqual_xml
#> {xml_document}
#> <airdata provider="Department of Environment and Science" state="Queensland" country="Australia">
#> [1] <category name="Air Quality" measurementhour="12" measurementdate="2020-1 ...