<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLElement/attributes",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLElement(py)attributes"
  },
  "title" : "attributes"
}
-->

# attributes

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

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

## Parameters

`attributes`

An array of [`XMLNode`](/documentation/Foundation/XMLNode) objects of kind [`XMLNode.Kind.attribute`](/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

To set attributes in an element node using an [`NSDictionary`](/documentation/Foundation/NSDictionary) object as the input parameter, see [`setAttributesWith(_:)`](/documentation/Foundation/XMLElement/setAttributesWith(_:)).

---

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)