Recipe: Converting XML into Trees

While many web services have moved to the simpler JSON format, XML is still a popular and powerful document encoding. iOS’s NSXMLParser class scans through XML, creating callbacks as new elements are processed and finished (that is, using the typical logic of a SAX parser). This class is terrific for when you’re downloading simple data feeds and want to scrape just a bit or two of relevant information. It might not be so great when you’re doing production-type work that relies on error checking, status information, and back-and-forth handshaking.

Recipe 13-6 retrieves the same weather forecast data from http://openweathermap.org as Recipe 13-5 but in XML format. It requests the xml mode rather than the json ...

Get The Core iOS Developer’s Cookbook, Fifth Edition 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.