Forum Discussion

violeta's avatar
15 years ago

generate a response based on request with multiple elements

Hi all!

I have a request like

<Person>
<BSN>BSN1</BSN>
</Person>
<Person>
<BSN>BSN2</BSN>
</Person>
<Person>
<BSN>BSN3</BSN>
</Person>


and I want to create a response like:

<Policies>
<Policy>
<BSN>BSN1</BSN>
<PolicyNo>ZBSN1</PolicyNo>
</Policy>

<Policy>
<BSN>BSN2</BSN>
<PolicyNo>ZBSN2</PolicyNo>
</Policy>

<Policy>
<BSN>BSN3</BSN>
<PolicyNo>ZBSN3</PolicyNo>
</Policy>
</Policies>

In other words, I want the BSN in the request to be taken from the BSN property, and the PolicyNo to be 'Z'+BSN

Everything's great, but only if there are no multiple elements.

I get a result like:


<Policy>
<BSN>BSN1BSN2BSN3</BSN>
<PolicyNo>ZBSN1BSN2BSN3</PolicyNo>
</Policy>


So all the values are appended.

How do I loop through the Person elements and for each Person element create a Policy element in the response?

Thanks!
No RepliesBe the first to reply