---
title: "parser(_:parseErrorOccurred:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmlparserdelegate/parser(_:parseerroroccurred:)"
---

# parser(_:parseErrorOccurred:)

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

## Declaration

```swift
optional func parser(_ parser: XMLParser, parseErrorOccurred parseError: any Error)
```

## Parameters

- `parser`: A parser object.
- `parseError`: An doc://com.apple.foundation/documentation/Foundation/NSError object describing the parsing error that occurred.

## Discussion

Discussion When this method is invoked, parsing is stopped. For further information about the error, you can query parseError or you can send the parser a parserError message. You can also send the parser lineNumber and columnNumber messages to further isolate where the error occurred. Typically you implement this method to display information about the error to the user.

## See Also

### Handling XML

- [parserDidStartDocument(_:)](foundation/xmlparserdelegate/parserdidstartdocument(_:).md)
- [parserDidEndDocument(_:)](foundation/xmlparserdelegate/parserdidenddocument(_:).md)
- [parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)](foundation/xmlparserdelegate/parser(_:didstartelement:namespaceuri:qualifiedname:attributes:).md)
- [parser(_:didEndElement:namespaceURI:qualifiedName:)](foundation/xmlparserdelegate/parser(_:didendelement:namespaceuri:qualifiedname:).md)
- [parser(_:didStartMappingPrefix:toURI:)](foundation/xmlparserdelegate/parser(_:didstartmappingprefix:touri:).md)
- [parser(_:didEndMappingPrefix:)](foundation/xmlparserdelegate/parser(_:didendmappingprefix:).md)
- [parser(_:resolveExternalEntityName:systemID:)](foundation/xmlparserdelegate/parser(_:resolveexternalentityname:systemid:).md)
- [parser(_:validationErrorOccurred:)](foundation/xmlparserdelegate/parser(_:validationerroroccurred:).md)
- [parser(_:foundCharacters:)](foundation/xmlparserdelegate/parser(_:foundcharacters:).md)
- [parser(_:foundIgnorableWhitespace:)](foundation/xmlparserdelegate/parser(_:foundignorablewhitespace:).md)
- [parser(_:foundProcessingInstructionWithTarget:data:)](foundation/xmlparserdelegate/parser(_:foundprocessinginstructionwithtarget:data:).md)
- [parser(_:foundComment:)](foundation/xmlparserdelegate/parser(_:foundcomment:).md)
- [parser(_:foundCDATA:)](foundation/xmlparserdelegate/parser(_:foundcdata:).md)
