title: SoapUI (Groovy) - passing a node value from a response to another request if a condition is true
body: <p>I would appreciate any help with following: </p>
  
  <p>XML Response:</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;SOAP-ENV:Header/&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;ns3:GetSeatPlanAvailabilityResponse xmlns:ns2="http://stagecoach.com/schemas/engine/common" xmlns:ns3="http://stagecoach.com/schemas/engine/seat"&gt;
           &lt;ns3:header&gt;
              &lt;ns2:version&gt;1.0&lt;/ns2:version&gt;
           &lt;/ns3:header&gt;
           &lt;ns3:journeyDetails&gt;
              &lt;ns2:journeyId&gt;4769046&lt;/ns2:journeyId&gt;
              &lt;ns2:origin&gt;
                 &lt;ns2:cityId&gt;120&lt;/ns2:cityId&gt;
                 &lt;ns2:description&gt;Memphis, TN&lt;/ns2:description&gt;
                 &lt;ns2:stop&gt;MEM&lt;/ns2:stop&gt;
              &lt;/ns2:origin&gt;
              &lt;ns2:destination&gt;
                 &lt;ns2:cityId&gt;320&lt;/ns2:cityId&gt;
                 &lt;ns2:description&gt;Austin, TX&lt;/ns2:description&gt;
                 &lt;ns2:stop&gt;AUS&lt;/ns2:stop&gt;
              &lt;/ns2:destination&gt;
              &lt;ns2:departureDate&gt;2014-07-28Z&lt;/ns2:departureDate&gt;
              &lt;ns2:departureTime&gt;04:00:00Z&lt;/ns2:departureTime&gt;
           &lt;/ns3:journeyDetails&gt;
           &lt;ns3:noOfNonReservableSeatsRemaining&gt;70&lt;/ns3:noOfNonReservableSeatsRemaining&gt;
           &lt;ns3:singleSeats&gt;
              &lt;ns2:singleSeat&gt;
                 &lt;ns2:seatPlanKey&gt;US1&lt;/ns2:seatPlanKey&gt;
                 &lt;ns2:seatId&gt;7ecc7775-6caa-4e17-80d7-6cfa46be507b&lt;/ns2:seatId&gt;
                 &lt;ns2:seatNumber&gt;1&lt;/ns2:seatNumber&gt;
                 &lt;ns2:seatClassCode&gt;FRN&lt;/ns2:seatClassCode&gt;
                 &lt;ns2:seatDeck&gt;UPPER&lt;/ns2:seatDeck&gt;
                 &lt;ns2:availableForSelection&gt;true&lt;/ns2:availableForSelection&gt;
              &lt;/ns2:singleSeat&gt;
              &lt;ns2:singleSeat&gt;
                 &lt;ns2:seatPlanKey&gt;US2&lt;/ns2:seatPlanKey&gt;
                 &lt;ns2:seatId&gt;fe73cc9a-7c4f-4d1f-80e5-6131926af694&lt;/ns2:seatId&gt;
                 &lt;ns2:seatNumber&gt;2&lt;/ns2:seatNumber&gt;
                 &lt;ns2:seatClassCode&gt;FRN&lt;/ns2:seatClassCode&gt;
                 &lt;ns2:seatDeck&gt;UPPER&lt;/ns2:seatDeck&gt;
                 &lt;ns2:availableForSelection&gt;true&lt;/ns2:availableForSelection&gt;
              &lt;/ns2:singleSeat&gt;
              &lt;ns2:singleSeat&gt;
  
                 &lt;ns2:seatPlanKey&gt;US3&lt;/ns2:seatPlanKey&gt;
                 &lt;ns2:seatId&gt;20121517-d657-438f-bc26-92bb98b20bb5&lt;/ns2:seatId&gt;
                 &lt;ns2:seatNumber&gt;3&lt;/ns2:seatNumber&gt;
                 &lt;ns2:seatClassCode&gt;FRN&lt;/ns2:seatClassCode&gt;
                 &lt;ns2:seatDeck&gt;UPPER&lt;/ns2:seatDeck&gt;
                 &lt;ns2:availableForSelection&gt;true&lt;/ns2:availableForSelection&gt;
              &lt;/ns2:singleSeat&gt;
              &lt;ns2:singleSeat&gt;
                 &lt;ns2:seatPlanKey&gt;US4&lt;/ns2:seatPlanKey&gt;
                 &lt;ns2:seatId&gt;b93be6b7-ebb9-482e-9ec2-3c9d32beab32&lt;/ns2:seatId&gt;
                 &lt;ns2:seatNumber&gt;4&lt;/ns2:seatNumber&gt;
                 &lt;ns2:seatClassCode&gt;FRN&lt;/ns2:seatClassCode&gt;
                 &lt;ns2:seatDeck&gt;UPPER&lt;/ns2:seatDeck&gt;
                 &lt;ns2:availableForSelection&gt;true&lt;/ns2:availableForSelection&gt;
    &lt;/ns2:singleSeat&gt;
           &lt;/ns3:singleSeats&gt;
           &lt;ns3:doubleSeats/&gt;
           &lt;ns3:salesClassInformation&gt;
              &lt;ns2:seatClassCode&gt;FRN&lt;/ns2:seatClassCode&gt;
              &lt;ns2:salesClassCode&gt;SFRN&lt;/ns2:salesClassCode&gt;
              &lt;ns2:salesClassDescription/&gt;
              &lt;ns2:price&gt;3.00&lt;/ns2:price&gt;
              &lt;ns2:maxPassengers&gt;1&lt;/ns2:maxPassengers&gt;
           &lt;/ns3:salesClassInformation&gt;
           &lt;ns3:salesClassInformation&gt;
              &lt;ns2:seatClassCode&gt;LEG&lt;/ns2:seatClassCode&gt;
              &lt;ns2:salesClassCode&gt;SLEG&lt;/ns2:salesClassCode&gt;
              &lt;ns2:salesClassDescription/&gt;
              &lt;ns2:price&gt;7.00&lt;/ns2:price&gt;
              &lt;ns2:maxPassengers&gt;1&lt;/ns2:maxPassengers&gt;
           &lt;/ns3:salesClassInformation&gt;
           &lt;ns3:salesClassInformation&gt;
              &lt;ns2:seatClassCode&gt;TBL&lt;/ns2:seatClassCode&gt;
              &lt;ns2:salesClassCode&gt;STBL&lt;/ns2:salesClassCode&gt;
              &lt;ns2:salesClassDescription/&gt;
              &lt;ns2:price&gt;9.00&lt;/ns2:price&gt;
              &lt;ns2:maxPassengers&gt;1&lt;/ns2:maxPassengers&gt;
           &lt;/ns3:salesClassInformation&gt;
        &lt;/ns3:GetSeatPlanAvailabilityResponse&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <hr>
  
  <p>XML Request:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bas="http://stagecoach.com/schemas/engine/basket" xmlns:com="http://stagecoach.com/schemas/engine/common"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;bas:AddSeatToBasketRequest&gt;
           &lt;bas:header&gt;
              &lt;com:version&gt;1.0&lt;/com:version&gt;
              &lt;com:retailOperation&gt;US&lt;/com:retailOperation&gt;
              &lt;com:channel&gt;WEB&lt;/com:channel&gt;
  
           &lt;/bas:header&gt;
           &lt;bas:basketItemId&gt;56227&lt;/bas:basketItemId&gt;
           &lt;!--1 or more repetitions:--&gt;
           &lt;bas:seatSelectionInput&gt;
              &lt;com:passengerOrdinal&gt;1&lt;/com:passengerOrdinal&gt;
              &lt;com:SeatId&gt;7ecc7775-6caa-4e17-80d7-6cfa46be507b&lt;/com:SeatId&gt;
           &lt;/bas:seatSelectionInput&gt;
           &lt;bas:seatSelectionInput&gt;
              &lt;com:passengerOrdinal&gt;2&lt;/com:passengerOrdinal&gt;
              &lt;com:SeatId&gt;d653b812-3230-4a31-88e7-a4ad867fb131&lt;/com:SeatId&gt;
           &lt;/bas:seatSelectionInput&gt;
        &lt;/bas:AddSeatToBasketRequest&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>My requirement is such that I need to pass <code>&lt;ns2:seatId&gt;</code> to another request, first it should look for condition when <code>&lt;ns2:availableForSelection&gt;</code> is <code>TRUE</code>, or else it should skip to 'FALSE' and select `and pass it to request</p>
  
  <p>Could some one please provide groovy script for above logic?</p>