Class

XMLParser

Instances of this class parse XML documents (including DTD declarations) in an event-driven manner. 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.

Overview

Nested Types

NSXMLParserError

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

NSXMLParserExternalEntityResolvingPolicy

Symbols

Initializing a Parser Object

init?(contentsOf: URL)

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

init(data: Data)

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

init(stream: InputStream)

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

Managing Delegates

var delegate: XMLParserDelegate?

A delegate object that receives messages about the parsing process.

Managing Parser Behavior

var shouldProcessNamespaces: Bool

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

var shouldReportNamespacePrefixes: Bool

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

var shouldResolveExternalEntities: Bool

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

Parsing

func parse()

Starts the event-driven parsing operation.

func abortParsing()

Stops the parser object.

var parserError: Error?

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

Obtaining Parser State

var columnNumber: Int

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

var lineNumber: Int

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

var publicID: String?

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

var systemID: String?

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

Constants

NSXMLParserErrorDomain

This constant defines the NSXMLParser error domain.

ErrorCode

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

Relationships

Inherits From

Conforms To