[resolved] How to parse SOAP response with looping element inside looping element

One Star

[resolved] How to parse SOAP response with looping element inside looping element

Hi Talenders,
I am faced with a problem with xml parsing. A webservice is returing data as below,
<?xml version="1.0" encoding="UTF-8"?>
<response>
<data_flux>
<item>return status</item>
<item>OK</item>
</data_flux>
<data_flux>
<item>workflow_name</item>
<item>WSProcessFlow</item>
</data_flux>
<data_flux>
<item>outdata</item>
<item>10000</item>
</data_flux>
<data_flux>
<item>indata</item>
<item>10</item>
</data_flux>
</response>

I am interested in getting <item>10000</item> which comes in the data_flux element with <item>outdata</item> out of that.
How should I go about it in tXMLMap? Any pointers?
Thanks,

Accepted Solutions
Sixteen Stars

Re: [resolved] How to parse SOAP response with looping element inside looping element

Use tExtractXMLField components. In this example you will need two; one to extract the first loop (and any other data at the first loop level) and one to extract the data from the inner loop. The first tExtractXMLField will need to extract the inner loop section as a "Node".
If you pass all of your data from the first tExtractXMLField to the second, then the values from the first tExtractXMLField that are not part of the inner loop will be multiplied for every inner loop. For example, building on yours.....

<response>
       <response_id>1</response_id>
<data_flux>
               <data_flux_id>1</data_flux_id>
<item>return status</item>
<item>OK</item>
</data_flux>
<data_flux>
<data_flux_id>2</data_flux_id>
               <item>workflow_name</item>
<item>WSProcessFlow</item>
</data_flux>
<data_flux>
               <data_flux_id>3</data_flux_id>
<item>outdata</item>
<item>10000</item>
</data_flux>
<data_flux>
               <data_flux_id>4</data_flux_id>
<item>indata</item>
<item>10</item>
</data_flux>
</response>

....would result in something like this.....
Response_Id, Data_flux_Id, Item
1,1,return status
1,1,OK
1,2,workflow_name
1,2,WSProcessFlow
1,3,outdata
1,3,10000
1,4,indata
1,4,10

All Replies
Sixteen Stars

Re: [resolved] How to parse SOAP response with looping element inside looping element

Use tExtractXMLField components. In this example you will need two; one to extract the first loop (and any other data at the first loop level) and one to extract the data from the inner loop. The first tExtractXMLField will need to extract the inner loop section as a "Node".
If you pass all of your data from the first tExtractXMLField to the second, then the values from the first tExtractXMLField that are not part of the inner loop will be multiplied for every inner loop. For example, building on yours.....

<response>
       <response_id>1</response_id>
<data_flux>
               <data_flux_id>1</data_flux_id>
<item>return status</item>
<item>OK</item>
</data_flux>
<data_flux>
<data_flux_id>2</data_flux_id>
               <item>workflow_name</item>
<item>WSProcessFlow</item>
</data_flux>
<data_flux>
               <data_flux_id>3</data_flux_id>
<item>outdata</item>
<item>10000</item>
</data_flux>
<data_flux>
               <data_flux_id>4</data_flux_id>
<item>indata</item>
<item>10</item>
</data_flux>
</response>

....would result in something like this.....
Response_Id, Data_flux_Id, Item
1,1,return status
1,1,OK
1,2,workflow_name
1,2,WSProcessFlow
1,3,outdata
1,3,10000
1,4,indata
1,4,10
One Star

Re: [resolved] How to parse SOAP response with looping element inside looping element

Thank you rhall. Thanks for pointing me towards tExtractXMLField It worked like a charm.