Book Image

iOS and OS X Network Programming Cookbook

By : Jon Hoffman
Book Image

iOS and OS X Network Programming Cookbook

By: Jon Hoffman

Overview of this book

Table of Contents (15 chapters)
iOS and OS X Network Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Parsing an RSS feed with NSXMLParser, NSURL, and NSData


While this recipe shows you how to parse an RSS feed using NSXMLParser, NSURL, and NSData, it is very easy to convert this code to parse any XML feed. All you need to do is change the tags that you are looking for.

In the previous recipes, we used NSURLConnection to access web services. For this recipe, we will be using the dataWithContentsFromURL: method of the NSData class to access a web service. We will assume that the response is an XML data feed and will use the NSXmlParser to parse the XML feed.

This recipe will load and parse the XML content synchronously. You will want to display an activity indicator to let the user know that the application did not freeze while the URL was loading. As in the synchronous HTTP GET and POST request recipes, it is recommended that we send the dataWithContentsFromURL: request in a separate thread. This allows us to display an activity indicator, letting the user know that we are loading information...