[[リクエストヘッダー]]の[[Content-Type]]に`application/xml`や`text/xml`が指定されている場合、[[Request helper (Mockoon)|Request helper]]の機能を使って[[XML]]の値にアクセスできる。
たとえば以下のリクエスト
```xml
curl -X POST "http://localhost:3001/xml/animal" -H "Content-type: text/xml" \
-d '<?xml version="1.0" encoding="utf-8"?>
<animal id="180702"></animal>'
```
[[xml-js]]の流儀に従うため、パスの間違いに注意。今回のケースだと`animal`タグの`id`属性にアクセスするので `animal._attributes.id`となる。
```xml
<?xml version="1.0" encoding="utf-8"?>
<animal id="{{body 'animal._attributes.id'}}">
<status>ok</status>
</animal>
```
![[Pasted image 20231203232746.png]]
実際にリクエストすると、レスポンスのid部分にちゃんと返却された。
```xml
<?xml version="1.0" encoding="utf-8"?>
<animal id="180702">
<status>ok</status>
</animal>
```
## [[CDATA]]を含む場合
https://www.npmjs.com/package/xml-js#options-for-changing-key-names
`._cdata`でアクセスする。
```xml
<?xml version="1.0" encoding="utf-8"?>
<animal>
<name>{{body 'animal._cdata'}}</name>
<status>ok</status>
</animal>
```
以下リクエストの`みみぞう`が入る感じ。
```xml
<?xml version="1.0" encoding="utf-8"?>
<animal><![CDATA[みみぞう]]></animal>
```