---
title: "parser(_:foundAttributeDeclarationWithName:forElement:type:defaultValue:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmlparserdelegate/parser(_:foundattributedeclarationwithname:forelement:type:defaultvalue:)"
---

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

## Declaration

```swift
optional func parser(_ parser: XMLParser, foundAttributeDeclarationWithName attributeName: String, forElement elementName: String, type: String?, defaultValue: String?)
```

## Parameters

- `parser`: An NSXMLParser object parsing XML.
- `attributeName`: A string that is the name of an attribute.
- `elementName`: A string that is the name of an element that has the attribute attributeName.
- `type`: A string, such as “ENTITY”, “NOTATION”, or “ID”, that indicates the type of the attribute.
- `defaultValue`: A string that specifies the default value of the attribute.

## See Also

### Related Documentation

- [parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)](foundation/xmlparserdelegate/parser(_:didstartelement:namespaceuri:qualifiedname:attributes:).md)

### Handling the DTD

- [parser(_:foundElementDeclarationWithName:model:)](foundation/xmlparserdelegate/parser(_:foundelementdeclarationwithname:model:).md)
- [parser(_:foundExternalEntityDeclarationWithName:publicID:systemID:)](foundation/xmlparserdelegate/parser(_:foundexternalentitydeclarationwithname:publicid:systemid:).md)
- [parser(_:foundInternalEntityDeclarationWithName:value:)](foundation/xmlparserdelegate/parser(_:foundinternalentitydeclarationwithname:value:).md)
- [parser(_:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:)](foundation/xmlparserdelegate/parser(_:foundunparsedentitydeclarationwithname:publicid:systemid:notationname:).md)
- [parser(_:foundNotationDeclarationWithName:publicID:systemID:)](foundation/xmlparserdelegate/parser(_:foundnotationdeclarationwithname:publicid:systemid:).md)
