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

# setAttributesWith(_:)

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

## Declaration

```swift
func setAttributesWith(_ attributes: [String : String])
```

## 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 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)
- [setAttributesAs(_:)](foundation/xmlelement/setattributesas(_:).md)
