0
votes

I have xml and want to remove tag which has empty values.

Source:  
<wd:Worktag_Reference>
   <wd:ID wd:type="abc">RISK_STATE_GA</wd:ID>
</wd:Worktag_Reference>
<wd:Worktag_Reference>
    <wd:ID wd:type="abcd"/>
</wd:Worktag_Reference>
<wd:Worktag_Reference>
    <wd:ID wd:type="abcde">LC011</wd:ID>
</wd:Worktag_Reference>

and I want output like this

Result:  
<wd:Worktag_Reference>
   <wd:ID wd:type="abc">RISK_STATE_GA</wd:ID>
</wd:Worktag_Reference>
<wd:Worktag_Reference>
    <wd:ID wd:type="abcde">LC011</wd:ID>
</wd:Worktag_Reference>
2

2 Answers

1
votes

You can use the filterObject function and remove the ones that their value is null. Also in my example I added the a tag name root as your xml was not valid

payload.root filterObject ((value, key, index) -> value.ID != null)

0
votes

You can use skipNullOn="everywhere" in Data weave.