Instance Method


Validates the document against the governing schema and returns whether the document conforms to the schema.


func validate() throws



If validation fails, on return contains an NSError object describing the reason or reasons for failure.

Return Value

true if the validation operation succeeded, otherwise false.


The constants indicating the kind of validation errors are emitted by the underlying parser; see NSXMLParser.h for most of these constants. If the schema is defined with a DTD, this method uses the XMLDTD object set for the receiver for validation. If the schema is based on XML Schema, the method uses the URL specified as the value of the xsi:schemaLocation attribute of the root element.

You can validate an XML document when it is first processed by specifying the NSXMLDocumentValidate option when you initialize an NSXMLDocument object with the init(contentsOf:options:), init(data:options:), or init(xmlString:options:) methods.

See Also