---
title: "parser(_:didStartMappingPrefix:toURI:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmlparserdelegate/parser(_:didstartmappingprefix:touri:)"
---

# 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.

## Declaration

```swift
optional func parser(_ parser: XMLParser, didStartMappingPrefix prefix: String, toURI namespaceURI: String)
```

## Parameters

- `parser`: A parser object.
- `prefix`: A string that is a namespace prefix.
- `namespaceURI`: A string that specifies a namespace URI.

## Discussion

Discussion The parser object sends this message only when namespace-prefix reporting is turned on through the shouldReportNamespacePrefixes method.

## 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(_:didEndMappingPrefix:)](foundation/xmlparserdelegate/parser(_:didendmappingprefix:).md)
- [parser(_:resolveExternalEntityName:systemID:)](foundation/xmlparserdelegate/parser(_:resolveexternalentityname:systemid:).md)
- [parser(_:parseErrorOccurred:)](foundation/xmlparserdelegate/parser(_:parseerroroccurred:).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)
