cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all the values from a duplicate tag and set the same in properties using groovy

Occasional Contributor

How to get all the values from a duplicate tag and set the same in properties using groovy

Hello All,

 

I have below XML response and want to capture all the values coming in a "FullText" tag.<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader eb:version="1.0" soap-env:mustUnderstand="1" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader">
<eb:From>
<ebSmiley TongueartyId eb:type="URI">123123</ebSmiley TongueartyId>
</eb:From>
<eb:To>
<ebSmiley TongueartyId eb:type="URI">99999</ebSmiley TongueartyId>
</eb:To>
<eb:CPAId>AAS</eb:CPAId>
<eb:ConversationId>test</eb:ConversationId>
<ebSmiley Frustratedervice eb:type="OTA">CDI</ebSmiley Frustratedervice>
<eb:Action>getReservationRS</eb:Action>
<eb:MessageData>
<eb:MessageId>732934421208470870</eb:MessageId>
<eb:Timestamp>2019-10-30T11:42:01</eb:Timestamp>
<eb:RefToMessageId>mid:20001209-133003-2333@clientofsabre.com</eb:RefToMessageId>
</eb:MessageData>
</eb:MessageHeader>
<wsseSmiley Frustratedecurity xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/STSB!ICESMSLB\/STS.LB!-2958029294769305206!947761!0</wsse:BinarySecurityToken>
</wsseSmiley Frustratedecurity>
</soap-env:Header>
<soap-env:Body>
<stl19:GetReservationRS Version="1.19.0" xmlns:stl19="http://webservices.sabre.com/pnrbuilder/v1_19" xmlns:ns6="http://services.sabre.com/res/orr/v0" xmlnsSmiley Surprisedr114="http://services.sabre.com/res/or/v1_14" xmlns:raw="http://tds.sabre.com/itinerary" xmlns:ns4="http://webservices.sabre.com/pnrconn/ReaccSearch">
<stl19:Reservation numberInParty="2" numberOfInfants="0" NumberInSegment="2" hostMarketedCodeShare="true">
<stl19:BookingDetails>
<stl19:RecordLocator>IVUTDX</stl19:RecordLocator>
<stl19:CreationTimestamp>2019-10-30T06:41:00</stl19:CreationTimestamp>
<stl19Smiley FrustratedystemCreationTimestamp>2019-10-30T06:41:00</stl19Smiley FrustratedystemCreationTimestamp>
<stl19:CreationAgentID>DJL</stl19:CreationAgentID>
<stl19:UpdateTimestamp>2019-10-30T06:41:59</stl19:UpdateTimestamp>
<stl19Smiley TongueNRSequence>2</stl19Smiley TongueNRSequence>
<stl19:FlightsRange Start="2019-11-20T20:50:00" End="2019-11-23T04:50:00"/>
<stl19Smiley Very HappyivideSplitDetails/>
<stl19:EstimatedPurgeTimestamp>2019-11-22T00:00:00</stl19:EstimatedPurgeTimestamp>
<stl19:UpdateToken>-40f1ee0d3c43ffa7e317052347c74ab6f00fc159d2c3a361</stl19:UpdateToken>
</stl19:BookingDetails>
<stl19Smiley TongueOS AirExtras="false" InhibitCode="U">
<stl19Smiley Frustratedource BookingSource="GH35" AgentSine="DJL" PseudoCityCode="GH35" ISOCountry="DE" AgentDutyCode="*" AirlineVendorID="AA" HomePseudoCityCode="HDQ" PrimeHostID="1S"/>
</stl19Smiley TongueOS>
<stl19Smiley TongueassengerReservation>
<stl19Smiley Tongueassengers>
<stl19Smiley Tongueassenger id="20" nameType="S" passengerType="ADT" nameId="01.01" nameAssocId="1" elementId="pnr-20.1">
<stl19:LastName>ZEEYEVU</stl19:LastName>
<stl19:FirstName>TYFEXH</stl19:FirstName>
<stl19Smiley FrustratedpecialRequests>
<stl19:GenericSpecialRequest id="25" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22WWWWWWWW0A1Z5/IBM/P</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22WWWWWWWW0A1Z5/IBM/P</stl19:FullText>
</stl19:GenericSpecialRequest>
<stl19:GenericSpecialRequest id="26" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22DDDWWWWW0A2S5/IBM/U</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22DDDWWWWW0A2S5/IBM/U</stl19:FullText>
</stl19:GenericSpecialRequest>
</stl19Smiley FrustratedpecialRequests>
<stl19Smiley Frustratedeats/>
</stl19Smiley Tongueassenger>
<stl19Smiley Tongueassenger id="22" nameType="S" passengerType="ADT" nameId="02.01" nameAssocId="2" elementId="pnr-22.2">
<stl19:LastName>NHFKDBG</stl19:LastName>
<stl19:FirstName>SVHJIT</stl19:FirstName>
<stl19Smiley FrustratedpecialRequests>
<stl19:GenericSpecialRequest id="27" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22SSSSAAA00A1Z5/IBM/S</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22SSSSAAA00A1Z5/IBM/S</stl19:FullText>
</stl19:GenericSpecialRequest>
<stl19:GenericSpecialRequest id="28" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22DDDDDDDDDD1Z5/IBM/P</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22DDDDDDDDDD1Z5/IBM/P</stl19:FullText>
</stl19:GenericSpecialRequest>
</stl19Smiley FrustratedpecialRequests>
<stl19Smiley Frustratedeats/>
</stl19Smiley Tongueassenger>
</stl19Smiley Tongueassengers>
<stl19Smiley Frustratedegments>
<stl19Smiley Tongueoc>
<stl19:Airport>EZE</stl19:Airport>
<stl19Smiley Very Happyeparture>2019-11-20T20:50:00</stl19Smiley Very Happyeparture>
</stl19Smiley Tongueoc>
<stl19Smiley Frustratedegment sequence="1" id="3">
<stl19:Air id="3" sequence="1" segmentAssociationId="2" isPast="false" DayOfWeekInd="3" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19Smiley Very HappyepartureAirport>EZE</stl19Smiley Very HappyepartureAirport>
<stl19Smiley Very HappyepartureAirportCodeContext>IATA</stl19Smiley Very HappyepartureAirportCodeContext>
<stl19:ArrivalAirport>MIA</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19Smiley SurprisedperatingAirlineCode>AA</stl19Smiley SurprisedperatingAirlineCode>
<stl19Smiley SurprisedperatingAirlineShortName>AMERICAN AIRLINES</stl19Smiley SurprisedperatingAirlineShortName>
<stl19Smiley SurprisedperatingFlightNumber>0900</stl19Smiley SurprisedperatingFlightNumber>
<stl19:EquipmentType>77W</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>0900</stl19:MarketingFlightNumber>
<stl19Smiley SurprisedperatingClassOfService>Y</stl19Smiley SurprisedperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19Smiley Frustratedequence>0</stl19Smiley Frustratedequence>
</stl19:MarriageGrp>
<stl19Smiley Frustratedeats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19Smiley Very HappyepartureDateTime>2019-11-20T20:50:00</stl19Smiley Very HappyepartureDateTime>
<stl19:ArrivalDateTime>2019-11-21T04:10:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>0900</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19Smiley FrustratedegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19Smiley SurprisedutboundConnection>false</stl19Smiley SurprisedutboundConnection>
<stl19Smiley FrustratedcheduleChangeIndicator>false</stl19Smiley FrustratedcheduleChangeIndicator>
<stl19Smiley FrustratedegmentBookedDate>2019-10-30T06:41:00</stl19Smiley FrustratedegmentBookedDate>
<stl19Smiley Tongueos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19Smiley Very HappyutyCode>*</stl19Smiley Very HappyutyCode>
</stl19Smiley Tongueos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19Smiley Frustratedegment>
<stl19Smiley Frustratedegment sequence="2" id="9">
<stl19:Air id="9" sequence="2" segmentAssociationId="3" isPast="false" DayOfWeekInd="4" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19Smiley Very HappyepartureAirport>MIA</stl19Smiley Very HappyepartureAirport>
<stl19Smiley Very HappyepartureAirportCodeContext>IATA</stl19Smiley Very HappyepartureAirportCodeContext>
<stl19:ArrivalAirport>EZE</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19Smiley SurprisedperatingAirlineCode>AA</stl19Smiley SurprisedperatingAirlineCode>
<stl19Smiley SurprisedperatingAirlineShortName>AMERICAN AIRLINES</stl19Smiley SurprisedperatingAirlineShortName>
<stl19Smiley SurprisedperatingFlightNumber>0907</stl19Smiley SurprisedperatingFlightNumber>
<stl19:EquipmentType>772</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>0907</stl19:MarketingFlightNumber>
<stl19Smiley SurprisedperatingClassOfService>Y</stl19Smiley SurprisedperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19Smiley Frustratedequence>0</stl19Smiley Frustratedequence>
</stl19:MarriageGrp>
<stl19Smiley Frustratedeats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19Smiley Very HappyepartureDateTime>2019-11-21T20:00:00</stl19Smiley Very HappyepartureDateTime>
<stl19:ArrivalDateTime>2019-11-22T07:07:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>0907</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19Smiley FrustratedegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19Smiley SurprisedutboundConnection>false</stl19Smiley SurprisedutboundConnection>
<stl19Smiley FrustratedcheduleChangeIndicator>false</stl19Smiley FrustratedcheduleChangeIndicator>
<stl19Smiley FrustratedegmentBookedDate>2019-10-30T06:41:00</stl19Smiley FrustratedegmentBookedDate>
<stl19Smiley Tongueos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19Smiley Very HappyutyCode>*</stl19Smiley Very HappyutyCode>
</stl19Smiley Tongueos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19Smiley Frustratedegment>
<stl19Smiley Frustratedegment sequence="3" id="15">
<stl19:Air id="15" sequence="3" segmentAssociationId="4" isPast="false" DayOfWeekInd="5" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19Smiley Very HappyepartureAirport>EZE</stl19Smiley Very HappyepartureAirport>
<stl19Smiley Very HappyepartureAirportCodeContext>IATA</stl19Smiley Very HappyepartureAirportCodeContext>
<stl19:ArrivalAirport>MIA</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19Smiley SurprisedperatingAirlineCode>4M</stl19Smiley SurprisedperatingAirlineCode>
<stl19Smiley SurprisedperatingAirlineShortName>LATAM AIRLINES ARGENTINA</stl19Smiley SurprisedperatingAirlineShortName>
<stl19Smiley SurprisedperatingFlightNumber>7820</stl19Smiley SurprisedperatingFlightNumber>
<stl19:EquipmentType>763</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>7836</stl19:MarketingFlightNumber>
<stl19Smiley SurprisedperatingClassOfService>Y</stl19Smiley SurprisedperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:CodeShareOperatingRecordLocator>IVUTMY</stl19:CodeShareOperatingRecordLocator>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19Smiley Frustratedequence>0</stl19Smiley Frustratedequence>
</stl19:MarriageGrp>
<stl19Smiley Frustratedeats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19Smiley Very HappyepartureDateTime>2019-11-22T21:35:00</stl19Smiley Very HappyepartureDateTime>
<stl19:ArrivalDateTime>2019-11-23T04:50:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>7836</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19Smiley FrustratedegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19Smiley SurprisedutboundConnection>false</stl19Smiley SurprisedutboundConnection>
<stl19Smiley FrustratedcheduleChangeIndicator>false</stl19Smiley FrustratedcheduleChangeIndicator>
<stl19Smiley FrustratedegmentBookedDate>2019-10-30T06:41:00</stl19Smiley FrustratedegmentBookedDate>
<stl19Smiley Tongueos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19Smiley Very HappyutyCode>*</stl19Smiley Very HappyutyCode>
</stl19Smiley Tongueos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19Smiley Frustratedegment>
</stl19Smiley Frustratedegments>
<stl19:TicketingInfo>
<stl19:TicketingTimeLimit id="29" index="1" elementId="pnr-29">
<stl19:Time>TL30</stl19:Time>
</stl19:TicketingTimeLimit>
</stl19:TicketingInfo>
<stl19:ItineraryPricing/>
</stl19Smiley TongueassengerReservation>
<stl19:ReceivedFrom>
<stl19:Name>QA</stl19:Name>
</stl19:ReceivedFrom>
<stl19Smiley TonguehoneNumbers>
<stl19Smiley TonguehoneNumber id="24" index="1" elementId="pnr-24">
<stl19:CityCode>STR</stl19:CityCode>
<stl19:Number>594999</stl19:Number>
</stl19Smiley TonguehoneNumber>
</stl19Smiley TonguehoneNumbers>
<stl19:EmailAddresses/>
<stl19Smiley SurprisedpenReservationElements>
<or114Smiley SurprisedpenReservationElement id="25" type="SRVC" elementId="pnr-25">
<or114Smiley FrustratederviceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22WWWWWWWW0A1Z5/IBM/P</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22WWWWWWWW0A1Z5/IBM/P</or114:FullText>
</or114Smiley FrustratederviceRequest>
<or114:NameAssociation>
<or114:LastName>ZEEYEVU</or114:LastName>
<or114:FirstName>TYFEXH</or114:FirstName>
<or114:NameRefNumber>01.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114Smiley SurprisedpenReservationElement>
<or114Smiley SurprisedpenReservationElement id="26" type="SRVC" elementId="pnr-26">
<or114Smiley FrustratederviceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22DDDWWWWW0A2S5/IBM/U</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22DDDWWWWW0A2S5/IBM/U</or114:FullText>
</or114Smiley FrustratederviceRequest>
<or114:NameAssociation>
<or114:LastName>ZEEYEVU</or114:LastName>
<or114:FirstName>TYFEXH</or114:FirstName>
<or114:NameRefNumber>01.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114Smiley SurprisedpenReservationElement>
<or114Smiley SurprisedpenReservationElement id="27" type="SRVC" elementId="pnr-27">
<or114Smiley FrustratederviceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22SSSSAAA00A1Z5/IBM/S</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22SSSSAAA00A1Z5/IBM/S</or114:FullText>
</or114Smiley FrustratederviceRequest>
<or114:NameAssociation>
<or114:LastName>NHFKDBG</or114:LastName>
<or114:FirstName>SVHJIT</or114:FirstName>
<or114:NameRefNumber>02.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114Smiley SurprisedpenReservationElement>
<or114Smiley SurprisedpenReservationElement id="28" type="SRVC" elementId="pnr-28">
<or114Smiley FrustratederviceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22DDDDDDDDDD1Z5/IBM/P</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22DDDDDDDDDD1Z5/IBM/P</or114:FullText>
</or114Smiley FrustratederviceRequest>
<or114:NameAssociation>
<or114:LastName>NHFKDBG</or114:LastName>
<or114:FirstName>SVHJIT</or114:FirstName>
<or114:NameRefNumber>02.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114Smiley SurprisedpenReservationElement>
</stl19Smiley SurprisedpenReservationElements>
</stl19:Reservation>
</stl19:GetReservationRS>
</soap-env:Body>
</soap-env:Envelope>

 

I have used below groovy script and able to print all the values but unable to set the same in property. I want each value to be set in property :

 

import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def xmlHolder = groovyUtils.getXmlHolder("GetReservation#Response")

def val = xmlHolder["//*:FullText"]
def count = xmlHolder["count(//*:FullText)"]
def SsrFullText="";
log.info count
for(i=1;i<count.toInteger();i++){
//log.info val[i] // it will print all the values from duplicate SSR Text
SsrFullText=val[i];
log.info SsrFullText
context.testCase.testSuite.setPropertyValue('SsrFullText',SsrFullText)


}

 

 

2 REPLIES 2
Community Hero

Re: How to get all the values from a duplicate tag and set the same in properties using groovy

What would you like to do after collecting the values?
Properties can only hold String key value pairs.
You are facing problem as you are trying to store the list.


Regards,
Rao.
Occasional Contributor

Re: How to get all the values from a duplicate tag and set the same in properties using groovy

I will store those values and then assert them with the values coming in other responses.

Is there a way to fetch values from the list.

 

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors