Getting started Community Training Tutorials Documentation APIs, AI & Tools
%dw 2.0
output application/xml inlineCloseOn="empty"
---
payload
Output self-closing XML tags
Output self-closing XML tags
This version of the product has reached End of Life.
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.
%dw 2.0
output application/xml inlineCloseOn="empty"
---
payload
{
"customer":{
"userName": "John Doe",
"password":{},
"status":"active",
"lastLogin":{}
}
}
<?xml version='1.0' encoding='UTF-8'?>
<customer>
<userName>John Doe</userName>
<password/>
<status>active</status>
<lastLogin/>
</customer>