O'Reilly logo

iPhone and iPad App 24-Hour Trainer by Gene Backlin, Abhishek Mishra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 27

XML Parsing with NSXMLParser

XML is an extremely popular format for data interchange and is used widely in desktop, mobile, and web applications. In this lesson you learn to parse XML documents in your applications.

XML stands for Extensible Markup Language and is a text-based markup language that lets you define the structure of a document. It is primarily used as a means to store and transfer data. Because it is text-based, XML files can be created and edited using almost any text editor capable of editing plain text files. If you decide to use TextEdit to edit XML files, be sure to use the Format ⇒ Make Plain Text menu item to ensure that TextEdit treats the XML document as plan text and not RTF.

Essentially, the author of an XML document creates structure within the document by creating several tags and inserting the content of the document within these tags. This is perhaps best understood with a simple example:

<contact>
    <first_name>John</first_name>
    <last_name>Doe</last_name>
    <address>15 Bilton Road, Perivale</address>
</contact>

The preceding snippet is a simple XML document that could be used to store information about a single contact, perhaps as part of a contacts management application.

The key thing to note is that XML is just a means to store/exchange data. There is no fixed set of tags that must be used in an XML document; you can create your own tags to structure your data.

An XML document on its own does not do anything. You need one or more applications ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required