Chapter 20. XML

WHAT'S IN THIS CHAPTER?

  • Making F# work with XML

  • Using Linq to XML with F#

  • Understanding how F# and DOM work together

  • Applying active patterns for XML parsing

XML is a fact of life for most software developers, regardless of language. It is found everywhere, from configuration files holding nothing but a small number of settings, to the giant stores of weather data provided in XML format by the National Oceanic and Atmospheric Administration of the United States. Although history will judge whether having all this XML was a good idea, the fact remains that it's there. Love it or hate it, developers have to deal with it.

In this chapter, you learn how to use F# with XML processing tools such as those found in the System.Xml namespace in the .NET framework. This chapter covers techniques that simplify most XML processing tasks. Special attention is provided to demonstrate how you can use things such as XPath and active patterns to simplify the task of processing and transforming XML.

OVERVIEW

Boiled down to its essence, most things that deal with XML do the following:

  • Read XML, typically to store it in some sort of language representation

  • Query the XML, often again to extract parts of it into some sort of language representation

  • Process the XML, sometimes to produce more XML or to generate some side effect

  • Persist the XML, so that other programs can join in the fun of working with XML

For more details on the various W3C standards that make up the XML grammar and suite of specifications, ...

Get Professional F# 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.