soapuiframework
12 years agoOccasional Contributor
Finding the xpath of a element using bottom to up approach
Hi,
I need some help in xpath or groovy code. I am struggling to find the solution to my problem.
XML Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<OTA_HotelAvailRS TimeStamp="2013-09-26T13:10:32" Target="Production" Version="1" xmlns="http://www.opentravel.org/OTA/2003/05">
<Success/>
<RoomStays>
<RoomStay>
<RoomTypes>
<RoomType RoomTypeCode="26093" RoomID="B26093">
<RoomDescription>
<Text>1 Bedroom Penthouse Suite Double - Room Only</Text>
</RoomDescription>
</RoomType>
</RoomTypes>
<RoomRates>
<RoomRate RoomTypeCode="26093" NumberOfUnits="1">
<Rates>
<Rate>
<Total AmountAfterTax="2659.61" CurrencyCode="EUR"/>
</Rate>
</Rates>
</RoomRate>
</RoomRates>
<GuestCounts>
<GuestCount AgeQualifyingCode="10" Count="2"/>
</GuestCounts>
<TimeSpan Start="2013-10-01" Duration="P5N"/>
<BasicPropertyInfo ChainCode="YX" HotelCode="79800" HotelName="Bellagio"/>
<TPA_Extensions>
<SortOrder>57</SortOrder>
</TPA_Extensions>
</RoomStay>
<RoomStay>
<RoomTypes>
<RoomType RoomTypeCode="26093RO" RoomID="B26093">
<RoomDescription>
<Text>1 Bedroom Penthouse Suite Double - Room Only</Text>
</RoomDescription>
</RoomType>
</RoomTypes>
<RoomRates>
<RoomRate RoomTypeCode="26093RO" NumberOfUnits="1">
<Rates>
<Rate>
<Total AmountAfterTax="2659.61" CurrencyCode="EUR"/>
</Rate>
</Rates>
</RoomRate>
</RoomRates>
<GuestCounts>
<GuestCount AgeQualifyingCode="10" Count="2"/>
</GuestCounts>
<TimeSpan Start="2013-10-30" Duration="P5N"/>
<BasicPropertyInfo ChainCode="BNT" HotelCode="79886" HotelName="Bellagio"/>
<TPA_Extensions>
<SortOrder>57</SortOrder>
</TPA_Extensions>
</RoomStay>
</RoomStays>
</OTA_HotelAvailRS>
</soap:Body>
</soap:Envelope>
Based on above code I am looking for an xpath code for the below Scenario:
Scenario 1: It should loop through all nodes and once match is found then it should take value from it's parent element. If ChainCode="BNT" Then return Start="2013-10-30" from matching node
Scenario 2: It should loop through all nodes and once match is found then it should take value from it's parent element. If ChainCode="BNT" Then return RoomTypeCode="26093RO" from matching node
Appreciate your help.
Best Regards,
Kam
I need some help in xpath or groovy code. I am struggling to find the solution to my problem.
XML Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<OTA_HotelAvailRS TimeStamp="2013-09-26T13:10:32" Target="Production" Version="1" xmlns="http://www.opentravel.org/OTA/2003/05">
<Success/>
<RoomStays>
<RoomStay>
<RoomTypes>
<RoomType RoomTypeCode="26093" RoomID="B26093">
<RoomDescription>
<Text>1 Bedroom Penthouse Suite Double - Room Only</Text>
</RoomDescription>
</RoomType>
</RoomTypes>
<RoomRates>
<RoomRate RoomTypeCode="26093" NumberOfUnits="1">
<Rates>
<Rate>
<Total AmountAfterTax="2659.61" CurrencyCode="EUR"/>
</Rate>
</Rates>
</RoomRate>
</RoomRates>
<GuestCounts>
<GuestCount AgeQualifyingCode="10" Count="2"/>
</GuestCounts>
<TimeSpan Start="2013-10-01" Duration="P5N"/>
<BasicPropertyInfo ChainCode="YX" HotelCode="79800" HotelName="Bellagio"/>
<TPA_Extensions>
<SortOrder>57</SortOrder>
</TPA_Extensions>
</RoomStay>
<RoomStay>
<RoomTypes>
<RoomType RoomTypeCode="26093RO" RoomID="B26093">
<RoomDescription>
<Text>1 Bedroom Penthouse Suite Double - Room Only</Text>
</RoomDescription>
</RoomType>
</RoomTypes>
<RoomRates>
<RoomRate RoomTypeCode="26093RO" NumberOfUnits="1">
<Rates>
<Rate>
<Total AmountAfterTax="2659.61" CurrencyCode="EUR"/>
</Rate>
</Rates>
</RoomRate>
</RoomRates>
<GuestCounts>
<GuestCount AgeQualifyingCode="10" Count="2"/>
</GuestCounts>
<TimeSpan Start="2013-10-30" Duration="P5N"/>
<BasicPropertyInfo ChainCode="BNT" HotelCode="79886" HotelName="Bellagio"/>
<TPA_Extensions>
<SortOrder>57</SortOrder>
</TPA_Extensions>
</RoomStay>
</RoomStays>
</OTA_HotelAvailRS>
</soap:Body>
</soap:Envelope>
Based on above code I am looking for an xpath code for the below Scenario:
Scenario 1: It should loop through all nodes and once match is found then it should take value from it's parent element. If ChainCode="BNT" Then return Start="2013-10-30" from matching node
Scenario 2: It should loop through all nodes and once match is found then it should take value from it's parent element. If ChainCode="BNT" Then return RoomTypeCode="26093RO" from matching node
Appreciate your help.
Best Regards,
Kam