---
title: attributes
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/xmlelement/attributes
---

# attributes

Sets all attributes of the receiver at once, replacing any existing attribute nodes.

## Declaration

```swift
var attributes: [XMLNode]? { get set }
```

## Parameters

- `attributes`: An array of doc://com.apple.foundation/documentation/Foundation/XMLNode objects of kind doc://com.apple.foundation/documentation/Foundation/XMLNode/Kind-swift.enum/attribute. If there are attribute nodes with the same name, the first attribute with that name is used. Send this message with attributes as nil to remove all attributes.

## Discussion

Discussion To set attributes in an element node using an NSDictionary object as the input parameter, see setAttributesWith(_:).

## See Also

### Handling Attributes

- [addAttribute(_:)](foundation/xmlelement/addattribute(_:).md)
- [attribute(forName:)](foundation/xmlelement/attribute(forname:).md)
- [attribute(forLocalName:uri:)](foundation/xmlelement/attribute(forlocalname:uri:).md)
- [removeAttribute(forName:)](foundation/xmlelement/removeattribute(forname:).md)
- [setAttributesWith(_:)](foundation/xmlelement/setattributeswith(_:).md)
- [setAttributesAs(_:)](foundation/xmlelement/setattributesas(_:).md)
