<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/attribute(withName:uri:stringValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLNode(cm)attributeWithName:URI:stringValue:"
  },
  "title" : "attribute(withName:uri:stringValue:)"
}
-->

# attribute(withName:uri:stringValue:)

Returns an `NSXMLNode` object representing an attribute node with a given qualified name and string.

```
class func attribute(withName name: String, uri URI: String, stringValue: String) -> Any
```

## Parameters

`name`

A string that is the name of an attribute.

`URI`

A URI (Universal Resource Identifier) that qualifies `name`.

`stringValue`

A string that is the value of the attribute.

## Return Value

An `NSXMLNode` object of kind [`XMLNode.Kind.attribute`](/documentation/Foundation/XMLNode/Kind-swift.enum/attribute) or `nil` if the object couldn’t be created.

## Discussion

For example, in the attribute “bst:id=`12345’”, “bst” is the name qualifier (derived from the URI), “id” is the attribute name, and “12345” is the attribute value.

---

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)