---
schema_version: "1"
id: e7ddfd83368ae8c77947914e808735b7e519879375301e5d120e646b5ae20c8e
title: attr
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-values-functions-attr.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-values-functions-attr
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4607a5ee1c32f328f7c33c81c53c5a25f7a923b668d670e6c86d6020e21e39f3
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# attr

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## attr(namespace: Namespace | Null = null, name: String): PathElement

This function creates a `PathElement` to use for selecting an XML attribute and populates the type’s
`selector` field with the given string.

Some versions of the `update` and `mask` functions accept a `PathElement` as an argument.

_Introduced in DataWeave version 2.2.2._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>namespace</code></p></td><td><p>The namespace of the attribute to select. If not specified, a null value is set.</p></td></tr><tr><td><p><code>name</code></p></td><td><p>The string that names the attribute to select.</p></td></tr></tbody></table>

### Example

This example creates an attribute selector for a specified namespace (`ns0`) and sets the selector’s
value to `"myAttr"`. In the output, also note that the value of the `"kind"` key is `"Attribute"`.

#### Source

```DataWeave
%dw 2.0
output application/json
import * from dw::util::Values
ns ns0 http://acme.com/fo
---
attr(ns0 , "myAttr")
```

#### Output

```Json
{
   "kind": "Attribute",
   "namespace": "http://acme.com/foo",
   "selector": "myAttr"
 }
```
