Class

NSXMLParser

An event driven parser of XML documents (including DTD declarations).

Declaration

@interface NSXMLParser : NSObject

Overview

An NSXMLParser notifies its delegate about the items (elements, attributes, CDATA blocks, comments, and so on) that it encounters as it processes an XML document. It does not itself do anything with those parsed items except report them. It also reports parsing errors. For convenience, an NSXMLParser object in the following descriptions is sometimes referred to as a parser object. Unless used in a callback, the NSXMLParser is a thread-safe class as long as any given instance is only used in one thread.

Topics

Initializing a Parser Object

- initWithContentsOfURL:

Initializes a parser with the XML content referenced by the given URL.

- initWithData:

Initializes a parser with the XML contents encapsulated in a given data object.

- initWithStream:

Initializes a parser with the XML contents from the specified stream and parses it..

Managing Delegates

delegate

A delegate object that receives messages about the parsing process.

Managing Parser Behavior

shouldProcessNamespaces

A Boolean value that determines whether the parser reports the namespaces and qualified names of elements.

shouldReportNamespacePrefixes

A Boolean value that determines whether the parser reports the prefixes indicating the scope of namespace declarations.

shouldResolveExternalEntities

A Boolean value that determines whether the parser reports declarations of external entities.

Parsing

- parse

Starts the event-driven parsing operation.

- abortParsing

Stops the parser object.

parserError

An NSError object from which you can obtain information about a parsing error.

Obtaining Parser State

columnNumber

The column number of the XML document being processed by the parser.

lineNumber

The line number of the XML document being processed by the parser.

publicID

The public identifier of the external entity referenced in the XML document.

systemID

The system identifier of the external entity referenced in the XML document.

Constants

NSXMLParserErrorDomain

Indicates an error in XML parsing.

NSXMLParserError

The following error codes are defined by NSXMLParser. For error codes not listed here, see the <libxml/xmlerror.h> header file.

Relationships

Inherits From

See Also

Event-Based Processing

NSXMLParserDelegate

The interface an XML parser uses to inform its delegate about the content of the parsed document.