---
title: "attribute(withName:uri:stringValue:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/xmlnode/attribute(withname:uri:stringvalue:)"
---

# attribute(withName:uri:stringValue:)

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

## Declaration

```swift
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

Return Value An NSXMLNode object of kind XMLNode.Kind.attribute or nil if the object couldn’t be created.

## Discussion

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.

## See Also

### Creating and Initializing Node Objects

- [init(kind:)](foundation/xmlnode/init(kind:).md)
- [init(kind:options:)](foundation/xmlnode/init(kind:options:).md)
- [document()](foundation/xmlnode/document().md)
- [document(withRootElement:)](foundation/xmlnode/document(withrootelement:).md)
- [element(withName:)](foundation/xmlnode/element(withname:).md)
- [element(withName:children:attributes:)](foundation/xmlnode/element(withname:children:attributes:).md)
- [element(withName:stringValue:)](foundation/xmlnode/element(withname:stringvalue:).md)
- [element(withName:uri:)](foundation/xmlnode/element(withname:uri:).md)
- [attribute(withName:stringValue:)](foundation/xmlnode/attribute(withname:stringvalue:).md)
- [text(withStringValue:)](foundation/xmlnode/text(withstringvalue:).md)
- [comment(withStringValue:)](foundation/xmlnode/comment(withstringvalue:).md)
- [namespace(withName:stringValue:)](foundation/xmlnode/namespace(withname:stringvalue:).md)
- [dtdNode(withXMLString:)](foundation/xmlnode/dtdnode(withxmlstring:).md)
- [predefinedNamespace(forPrefix:)](foundation/xmlnode/predefinednamespace(forprefix:).md)
- [processingInstruction(withName:stringValue:)](foundation/xmlnode/processinginstruction(withname:stringvalue:).md)
