This is a mirror of official site: http://jasper-net.blogspot.com/

Objective-C Fundamentals - NSXMLParser

| Sunday, September 4, 2011
Apple provides a class called NSXMLParser to iPhone developers. Developers use this class when parsing XML. Several open source alternatives to NSXMLParser are available and used by many developers, but we are going to look at the delegate methods of the standard Cocoa XML Parser.

There is no <NSXMLParser> protocol; you will receive no warning if you do not declare this in the header of the application you are creating. NSXMLParser is a fringe design class that follows the principles of protocol design but doesn’t explicitly define a protocol. An NSXMLParser object has a parameter called delegate, which needs to be defined. Whatever object is defined as the delegate has the option of implementing a collection of 20 different delegate methods. NSXMLParser provides delegate methods that handle every point of parsing for both XML- and DTD-based documents.

XML is a type of file that can hold data in a very structured manner. As a quick introduction, XML uses the syntax of HTML to create unique data structures. An example of an XML element that describes a person is shown in listing 1.
Listing 1 An Author in XML

<Author>
    <name>Collin Ruffenach</name>
    <age>23</age>
    <gender>male</gender>
    <Books>
           <Book>
                  <title>Objective C for the iPhone</title>
                  <year>2010</year>
                  <level>intermediate</level>
              </Book>
    </Books>
</Author>


Read more: Codeproject
QR: NSXMLParser.aspx

Posted via email from Jasper-net

0 comments: