Episode #425

Parsing XML in Swift

30 minutes
Published on January 23, 2020

This video is only available to subscribers. Get access to this video and 497 others.

Sometimes legacy APIs that we have to deal with only support XML, and while Swift has first class support for JSON with Codable, XML parsing is still done with Foundation's XMLParser. This is a powerful yet difficult to use class that is modeled as a streaming XML parser. This means you have to write some code that keeps track of the values and state of where we are in the XML document in order to parse it. In this episode we will cover how to parse an XML document using multiple objects, parsers, and a delegate stack.

This episode uses Xcode 11.2.1, Swift 5.1.