---
schema_version: "1"
id: f17e1ba6d51a571184c8a29c654709cc49033365ca81f75b3548839392b9a141
title: Output Self-closing XML Tags
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dataweave-cookbook-output-self-closing-xml-tags.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dataweave-cookbook-output-self-closing-xml-tags
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4dd89bd9e08fa1c8f110e1c346c62f4ee7d74ab96c1ea316d157999e0a3e7ae4
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
keywords: studio, anypoint, transform, transformer, format, xml, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping
---

# Output Self-closing XML Tags

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

For XML, DataWeave by default outputs every value within an opening and closing tag, even if the tag
contains no value (for example, `<element2></element2>`).

To output empty tags as a self-closing XML element (for example, `<element2/>`), you can set the
`inlineCloseOn="empty"` output directive in the DataWeave header.

DataWeave Script:

```dataweave
%dw 2.0
output application/xml inlineCloseOn="empty"
---
payload
```

Input JSON Payload:

```json
{
  "customer": {
    "userName": "John Doe",
    "password": {},
    "status": "active",
    "lastLogin": {}
  }
}
```

Output XML:

```xml
<?xml version='1.0' encoding='UTF-8'?>
<customer>
  <userName>John Doe</userName>
  <password/>
  <status>active</status>
  <lastLogin/>
</customer>
```

## Related Examples

- [Insert an Attribute into an XML Tag](https://docs.mulesoft.com/dataweave/latest/dataweave-cookbook-insert-attribute)

- [Remove Specified XML Attributes](https://docs.mulesoft.com/dataweave/latest/dataweave-cookbook-remove-certain-xml-attributes)

- [Include XML Namespaces](https://docs.mulesoft.com/dataweave/latest/dataweave-cookbook-include-xml-namespaces)

## See Also

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

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