<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLDTD/attributeDeclaration(forName:elementName:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLDTD(im)attributeDeclarationForName:elementName:"
  },
  "title" : "attributeDeclaration(forName:elementName:)"
}
-->

# attributeDeclaration(forName:elementName:)

Returns the DTD node representing an attribute-list declaration for a given attribute and its element.

```
func attributeDeclaration(forName name: String, elementName: String) -> XMLDTDNode?
```

## Parameters

`name`

A string object identifying the name of an attribute.

`elementName`

A string object identifying the name of an element.

## Return Value

An autoreleased [`XMLDTDNode`](/documentation/Foundation/XMLDTDNode) object, or `nil` if there is no matching attribute-list declaration.

## Discussion

For example, in the attribute-list declaration:

```objc
<!ATTLIST person idnum CDATA "0000">
```

“idnum” would correspond to `attrName` and “person” would correspond to `elementName`.

---

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)