Search code examples
testingxpathpropertiessoapuitransfer

Another about XPath structure with SoapUI and Property Transfer - nested repeated tags


Yet another problem. This time I think because the tag is used twice in the same message, nested.

I have no issue retrieving other items with unique labels (like requestDateTime, statusDateTime and completedStateEnteredDate), but I can't successfully grab the <som> reference number, or the status (which is inside status) or the type (again, inside another <type> tag).

So I know my namespace works, just can't work out how to get the data I need. Specifically, I need to capture that numeric value in the <som>6000526</som> part. The data does return multiple SOM numbers, so the bonus would be how do I capture more than one (like the first 2 or 5 would be cool).

<return>
    <success>true</success>
    <networkUpdateList>
       <confirmationDue>
          <actualDays>26</actualDays>
          <actualHours>11</actualHours>
          <actualMinutes>57</actualMinutes>
          <businessDays>22</businessDays>
          <businessHours>7</businessHours>
          <businessMinutes>57</businessMinutes>
          <negative>true</negative>
       </confirmationDue>
       <confirmingCarrierId>11567</confirmingCarrierId>
       <numbers>
          <donorCarrierId>11657</donorCarrierId>
          <gainingCarrierId>11667</gainingCarrierId>
          <losingCarrierId>11657</losingCarrierId>
          <number>
             <phoneNumber>098453520</phoneNumber>
          </number>
       </numbers>
       <som>
          <requestDateTime>2017-04-11T10:08:01+12:00</requestDateTime>
          <som>6000526</som>
          <status>
             <status>GC and LC Complete</status>
          </status>
          <statusDateTime>2017-04-11T10:09:09+12:00</statusDateTime>
          <type>
             <type>Port</type>
          </type>
          <completedStateEnteredDate>2017-04-11T10:09:09+12:00</completedStateEnteredDate>
       </som>
    </networkUpdateList>

Solution

  • I staggered upon the solution, works for all duplicated names:
    //som/som does the job.
    As does //status/status and //type/type so I am a happy camper. I just don't know how to pick up the next occurrence within the response, but I don't desperately need that, I can just loop.
    Edit: Also discovered that
    (//som/som) [2]
    Returns the second occurence, and that (//som/som) [1] returns the first, etc. Very simple and good to know.
    Discovered here: https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx