Introduction to Event-Driven XML Programming Guide for Cocoa
XML is a markup language that allows you to describe the structure of a document’s data entirely in text, using tags that you can arbitrarily define. (“XML” stands for “Extensible Markup Language”.) The rules governing the structure are specified in a language schema such as DTD (Document Type Definition). Cocoa provides a class, NSXMLParser, whose instances are event-driven parsers (sometimes called streaming parsers) that sequentially find the constructs of an XML document as well as any associated DTD declarations. They report what they find to a delegate, and it is up to the delegate to do something with this data. This document explains how to use NSXMLParser.
Organization of This Document
This programming topic includes the following articles:
Parser Capabilities and Architecture gives an overview of how the Cocoa streaming parser (NSXMLParser) processes an XML document and what kinds of tasks it is best suited for.
XML Parsing Basics describes the essential steps for using NSXMLParser: creating and initializing the instance, responding to delegation messages, and handling parsing errors.
Handling XML Elements and Attributes offers suggestions and examples for handling XML attributes and elements, the most common kinds of XML constructs.
Handling Parsing Errors describes how to handle errors that the NSXMLParser object finds in the XML.
Using Multiple Delegates discusses the technique of using multiple delegates of the NSXMLParser instance to simplify and streamline XML processing.
Constructing XML Tree Structures gives some suggestions for creating DOM-style trees using NSXMLParser.
Validation Tips and Techniques offers suggestions for using NSXMLParser when validating an XML document against its DTD or other schema.
XML Glossary lists definitions of XML and DTD terms that are part of the NSXMLParser programmatic interface.
See Also
There are many websites that are rich sources of information on XML, DTD, XML tools, open-source parsers, and related specifications and technologies. A few of them are listed below, but a search of the Internet (with, for example, “XML tutorial” in the search field) will find many excellent sources of information:
World Wide Web Consortium — http://www.w3.org/
The Annotated XML Specification — http://www.xml.com/axml/testaxml.htm
O’Reilly XML.com — http://www.xml.com/
The XML parser and toolkit of Gnome (libxml) — http://xmlsoft.org/
Copyright © 2004, 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-03-24