<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLElement/attribute(forLocalName:uri:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLElement(im)attributeForLocalName:URI:"
  },
  "title" : "attribute(forLocalName:uri:)"
}
-->

# attribute(forLocalName:uri:)

Returns the attribute node of the receiver that is identified by a local name and URI.

```
func attribute(forLocalName localName: String, uri URI: String?) -> XMLNode?
```

## Parameters

`localName`

A string specifying the local name of an attribute.

`URI`

A sting identifying the URI associated with an attribute.

## Return Value

An XML node object representing a matching attribute or `nil` if no such node was found.

## Discussion

---

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)