Initializer

init(data:options:)

Initializes and returns an NSXMLDocument object created from an NSData object.

Declaration

init(data: Data, options mask: XMLNode.Options = []) throws

Parameters

data

A data object with XML content.

mask

A bit mask for input options. You can specify multiple options by bit-OR'ing them. See Constants for a list of valid input options.

error

An error object that, on return, identifies any parsing errors and warnings or connection problems.

Return Value

An initialized NSXMLDocument object, or nil if initialization fails because of parsing errors or other reasons.

Discussion

This method is the designated initializer for the NSXMLDocument class.

If you specify NSXMLDocumentTidyXML as one of the options, NSXMLDocument performs several clean-up operations on the document XML (such as removing leading tabs). It does respect the xml:space="preserve" attribute when it attempts to tidy the XML.

See Also

Initializing NSXMLDocument Objects

init(contentsOf: URL, options: XMLNode.Options)

Initializes and returns an NSXMLDocument object created from the XML or HTML contents of a URL-referenced source

init(rootElement: XMLElement?)

Returns an NSXMLDocument object initialized with a single child, the root element.

init(xmlString: String, options: XMLNode.Options)

Initializes and returns an NSXMLDocument object created from a string containing XML markup text.

class func replacementClass(for: AnyClass) -> AnyClass

Overridden by subclasses to substitute a custom class for an NSXML class that the parser uses to create node instances.