---
schema_version: "1"
id: 50bb4aacbe7f2c8e5851d217d96f62f3ce024cf26169dbdd560e3fbac85a00d6
title: Output Self-closing XML Tags
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dataweave-cookbook-output-self-closing-xml-tags.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dataweave-cookbook-output-self-closing-xml-tags
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 6180121b44a95f7a0e82bd771e9a0d1000253b30e5681efdc1e35bbf076ddeea
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
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/2.9/dataweave-cookbook-insert-attribute)

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

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

## See Also

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

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