---
schema_version: "1"
id: 797c4e2cc28dae78e2b19ddfa0c0336d79feba91f508d1a55743be969a3d9788
title: attr
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-values-functions-attr.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-values-functions-attr
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2e9c68e521e21df799f943a9d04a9976e768ba7dc73d0140a9a0407b22eef215
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# 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"
 }
```
