<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLParserDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSXMLParserDelegate"
  },
  "title" : "XMLParserDelegate"
}
-->

# XMLParserDelegate

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

```
protocol XMLParserDelegate : NSObjectProtocol
```

## Topics

### Handling XML

[`parserDidStartDocument(_:)`](/documentation/Foundation/XMLParserDelegate/parserDidStartDocument(_:))

Sent by the parser object to the delegate when it begins parsing a document.

[`parserDidEndDocument(_:)`](/documentation/Foundation/XMLParserDelegate/parserDidEndDocument(_:))

Sent by the parser object to the delegate when it has successfully completed parsing.

[`parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)`](/documentation/Foundation/XMLParserDelegate/parser(_:didStartElement:namespaceURI:qualifiedName:attributes:))

Sent by a parser object to its delegate when it encounters a start tag for a given element.

[`parser(_:didEndElement:namespaceURI:qualifiedName:)`](/documentation/Foundation/XMLParserDelegate/parser(_:didEndElement:namespaceURI:qualifiedName:))

Sent by a parser object to its delegate when it encounters an end tag for a specific element.

[`parser(_:didStartMappingPrefix:toURI:)`](/documentation/Foundation/XMLParserDelegate/parser(_:didStartMappingPrefix:toURI:))

Sent by a parser object to its delegate the first time it encounters a given namespace prefix, which is mapped to a URI.

[`parser(_:didEndMappingPrefix:)`](/documentation/Foundation/XMLParserDelegate/parser(_:didEndMappingPrefix:))

Sent by a parser object to its delegate when a given namespace prefix goes out of scope.

[`parser(_:resolveExternalEntityName:systemID:)`](/documentation/Foundation/XMLParserDelegate/parser(_:resolveExternalEntityName:systemID:))

Sent by a parser object to its delegate when it encounters a given external entity with a specific system ID.

[`parser(_:parseErrorOccurred:)`](/documentation/Foundation/XMLParserDelegate/parser(_:parseErrorOccurred:))

Sent by a parser object to its delegate when it encounters a fatal error.

[`parser(_:validationErrorOccurred:)`](/documentation/Foundation/XMLParserDelegate/parser(_:validationErrorOccurred:))

Sent by a parser object to its delegate when it encounters a fatal validation error. `NSXMLParser` currently does not invoke this method and does not perform validation.

[`parser(_:foundCharacters:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundCharacters:))

Sent by a parser object to provide its delegate with a string representing all or part of the characters of the current element.

[`parser(_:foundIgnorableWhitespace:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundIgnorableWhitespace:))

Reported by a parser object to provide its delegate with a string representing all or part of the ignorable whitespace characters of the current element.

[`parser(_:foundProcessingInstructionWithTarget:data:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundProcessingInstructionWithTarget:data:))

Sent by a parser object to its delegate when it encounters a processing instruction.

[`parser(_:foundComment:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundComment:))

Sent by a parser object to its delegate when it encounters a comment in the XML.

[`parser(_:foundCDATA:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundCDATA:))

Sent by a parser object to its delegate when it encounters a CDATA block.

### Handling the DTD

[`parser(_:foundAttributeDeclarationWithName:forElement:type:defaultValue:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundAttributeDeclarationWithName:forElement:type:defaultValue:))

Sent by a parser object to its delegate when it encounters a declaration of an attribute that is associated with a specific element.

[`parser(_:foundElementDeclarationWithName:model:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundElementDeclarationWithName:model:))

Sent by a parser object to its delegate when it encounters a declaration of an element with a given model.

[`parser(_:foundExternalEntityDeclarationWithName:publicID:systemID:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundExternalEntityDeclarationWithName:publicID:systemID:))

Sent by a parser object to its delegate when it encounters an external entity declaration.

[`parser(_:foundInternalEntityDeclarationWithName:value:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundInternalEntityDeclarationWithName:value:))

Sent by a parser object to the delegate when it encounters an internal entity declaration.

[`parser(_:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:))

Sent by a parser object to its delegate when it encounters an unparsed entity declaration.

[`parser(_:foundNotationDeclarationWithName:publicID:systemID:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundNotationDeclarationWithName:publicID:systemID:))

Sent by a parser object to its delegate when it encounters a notation declaration.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)