For the More Curious: Parsing XML
There are two standard approaches to parsing XML. The high-level method (DOM parsing) is to use NSXMLDocument and NSXMLNode. If you have an NSData object containing the following XML:
<?xml version="1.0" encoding="UTF-8"?> <people> <person> <first>Patrick</first> <last>Robinson</last> </person> </people>
NSXMLDocument will parse it into a handy tree (Figure 28.7):
Figure 28.7 Parsed XML document
You can then traverse the tree manually or use XPath queries ...
Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.