---
schema_version: "1"
id: 0a4a904e5c8081b4499a4d98f17cbf90700389ebc7a96a9fab2365f065bf5438
title: Exclude Fields from the Output
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dataweave-cookbook-exclude-field.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dataweave-cookbook-exclude-field
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 50e4a2d1b22d19f9b5ffab7b7988728ab9f656b616580aa088544a8db4225872
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
keywords: studio, anypoint, transform, transformer, format, xml, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping, remove, mapobject
---

# Exclude Fields from the Output

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

This DataWeave example excludes specific XML elements from the output. You might perform a task like
this to remove sensitive data.

The example uses these functions:

- `-` to remove specific `key:value` pairs (here, the `ssn` and `password` XML elements).

- `mapObject` to go through the XML elements.

DataWeave Script:

```dataweave
%dw 2.0
output application/xml
---
users: {
      (payload.users mapObject {
        user: {
        personal_information: $.personal_information - "ssn",
        login_information: $.login_information - "password"
        }
      })
}
```

Input XML Payload:

```xml
<users>
    <user>
        <personal_information>
            <first_name>Emiliano</first_name>
            <middle_name>Romoaldo</middle_name>
            <last_name>Lesende</last_name>
            <ssn>001-08-84382</ssn>
        </personal_information>
        <login_information>
            <username>3miliano</username>
            <password>mypassword1234</password>
        </login_information>
    </user>
    <user>
        <personal_information>
            <first_name>Mariano</first_name>
            <middle_name>Toribio</middle_name>
            <last_name>de Achaval</last_name>
            <ssn>002-05-34738</ssn>
        </personal_information>
        <login_information>
            <username>machaval</username>
            <password>mypassword4321</password>
        </login_information>
    </user>
</users>
```

Output XML:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<users>
  <user>
    <personal_information>
      <first_name>Emiliano</first_name>
      <middle_name>Romoaldo</middle_name>
      <last_name>Lesende</last_name>
    </personal_information>
    <login_information>
      <username>3miliano</username>
    </login_information>
  </user>
  <user>
    <personal_information>
      <first_name>Mariano</first_name>
      <middle_name>Toribio</middle_name>
      <last_name>de Achaval</last_name>
    </personal_information>
    <login_information>
      <username>machaval</username>
    </login_information>
  </user>
</users>
```

## Related Examples

- [Output a Field When Present](https://docs.mulesoft.com/dataweave/2.12/dataweave-cookbook-output-a-field-when-present)

- [Change the Value of a Field](https://docs.mulesoft.com/dataweave/2.12/dataweave-cookbook-change-value-of-a-field)

- [Conditionally Reduce a List through a Function](https://docs.mulesoft.com/dataweave/2.12/dataweave-cookbook-conditional-list-reduction-via-function)

## See Also

- [DataWeave Selectors](https://docs.mulesoft.com/dataweave/2.12/dataweave-selectors)

- [DataWeave Cookbook](https://docs.mulesoft.com/dataweave/2.12/dataweave-cookbook)
