fork download
  1. def str = '''<soap:Envelope xmlns:soap="http://s...content-available-to-author-only...p.org/soap/envelope/">
  2. <SOAP-ENV:Header xmlns:SOAP-ENV="http://s...content-available-to-author-only...p.org/soap/envelope/"/>
  3. <soap:Body>
  4. <ns2:OTA_HotelSearchRS AltLangID="en" EchoToken="20BB36F8AC152AC46E95033289D89328" PrimaryLangID="en" RetransmissionIndicator="false" Target="Test" TimeStamp="2019-04-07T15:35:51.869-07:00" TransactionIdentifier="SmokeTestHotelSearch" TransactionStatusCode="" Version="1.003" xmlns:ns2="http://w...content-available-to-author-only...l.org/OTA/2003/05">
  5. <ns2:Success/>
  6. <ns2:Properties>
  7. <ns2:Property ChainCode="ABC" HotelCode="03062">
  8. <ns2:RelativePosition Distance="3.0" Name="City Center" UnitOfMeasureCode="1"/>
  9. </ns2:Property>
  10. <ns2:Property ChainCode="ABC" HotelCode="03092">
  11. <ns2:RelativePosition Distance="7.44" Name="City Center" UnitOfMeasureCode="1"/>
  12. </ns2:Property>
  13. <ns2:Property ChainCode="ABC" HotelCode="03144">
  14. <ns2:RelativePosition Distance="8.04" Name="City Center" UnitOfMeasureCode="1"/>
  15. </ns2:Property>
  16. </ns2:Properties>
  17. </ns2:OTA_HotelSearchRS>
  18. </soap:Body>
  19. </soap:Envelope>'''
  20.  
  21. def xml = new XmlSlurper().parseText(str)
  22. def map = xml.'**'.findAll {'Property' == it.name()}.collectEntries{ [(it.@HotelCode.text()): it.@ChainCode.text()]}
  23. println map
Success #stdin #stdout 1.51s 2252800KB
stdin
Standard input is empty
stdout
[03062:ABC, 03092:ABC, 03144:ABC]