---
title: "setAttributesAs(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmlelement/setattributesas(_:)"
---

# setAttributesAs(_:)

Sets the attributes of the receiver based on the key-value pairs specified in the passed-in dictionary.

## Declaration

```swift
func setAttributesAs(_ attributes: [AnyHashable : Any])
```

## Parameters

- `attributes`: A dictionary of key-value pairs where the attribute name is the key and the object value of the attribute is the dictionary value.

## Discussion

Discussion The method uses these names and object values to create XMLNode objects of kind XMLNode.Kind.attribute. Existing attributes are not removed.

## 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)
- [attributes](foundation/xmlelement/attributes.md)
- [removeAttribute(forName:)](foundation/xmlelement/removeattribute(forname:).md)
- [setAttributesWith(_:)](foundation/xmlelement/setattributeswith(_:).md)
