Best way to output a node even if null? (foreach, choose does not output node as expected)
Content
How can I output a node as null if the foreach/choose condition is not met? Here's the source:
<appt>
<responses>
<answer>12312312312</answer>
<questionExternalID>alternatephonenumber</questionExternalID>
</responses>
<responses>
<answer/>
<questionExternalID>createdbyuser</questionExternalID>
</responses>
</appt>
I am attempting to map to this structure when a condition is met:
<response-wrapper> <alternatenumber>081111111</alternatenumber> </response-wrapper>
.. and this structure when it is not met:
<response-wrapper> <alternatenumber/> </response-wrapper>
The problem is that the response node is repeating so I must use a foreach loop. If I use an otherwise condition the alternatenumber node is output for each of the response nodes present, which is not what I want (I only want 1 alternatenumber node)
Tagged:
0