XML and the NSXMLParser class

To parse XML documents in Swift, we will use Apple's NSXMLParser class. While there are several alternatives to NSXMLParser, each with its own advantages and disadvantages, I have always found NSXMLParser to be simple to understand and use. It is also designed in a way that is consistent with Apple's other APIs, which means if we are familiar with Apple's other APIs, NSXMLParser will seem pretty straightforward.

The NSXMLParser class is a Simple API for XML (SAX) parser. SAX parsers provide a mechanism to parse XML documents sequentially. Unlike Document Object Model (DOM) parsers, which read the entire document into the memory and then parse it, a SAX parser reports on each parsing event as it happens. This allows ...

Get Swift: Developing iOS Applications 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.