I have a XML input and in one of the field its having space, using dataweve its treating space as null, I want to read the space as character.
XML Input:
<employee>
<id>123</id>
<name> </name>
</employee>
DataWeave script:
%dw 2.0
output application/xml
---
"root" : {
"id" : payload.employee.id,
"name" : if (payload.employee.name == " ") "space" else payload.employee.name
}
The output is coming as below:
<?xml version='1.0' encoding='UTF-8'?>
<root>
<id>123</id>
<name/>
</root>
Try below script :
%dw 2.0
output application/xml
---
"root" : {
"id" : payload.employee.id,
"name" : if (payload.employee.name is Null) "space" else payload.employee.name
}