Reputation: 49
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>
Upvotes: 0
Views: 2900
Reputation: 5059
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)
Upvotes: 1