---
schema_version: "1"
id: a9db634f1ac39e81d17092cc2bdd87bbd9f1bfb81059952fa999461d3dfced78
title: attr
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-values-functions-attr.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-values-functions-attr
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5d99fe028d19a6b79c77667246ba37a34b9e62b5819b1b0dcb8729dabb0f3909
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# attr

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

この関数は、XML 属性を選択するために使用する ​`PathElement`​ を作成し、型の ​`selector`​ 項目に特定の文字列を入力します。

`update`​ および ​`mask`​ 関数の一部のバージョンは、​`PathElement`​ を引数として受け入れます。

_DataWeave バージョン 2.2.2 で導入されました。_

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>namespace</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">選択する属性の名前空間。指定しない場合、null 値が設定されます。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">選択する属性の名前に設定する文字列。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、指定された名前空間 (​`ns0`​) の属性セレクターを作成し、セレクターの値を ​`"myAttr"`​ に設定します。出力で ​`"kind"`​ キーの値が ​`"Attribute"`​ になっていることにも注意してください。

#### [](#ソース)ソース

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

#### [](#出力)出力

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