我得到的SOAP xml响应如下:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:MultiAvailabilityResponse xmlns:ns2="http://www.derbysoft.com/doorway" Status="Successful" Token="187be58c62c2f2515b5d78ee">
<ns2:Availabilities>
<ns2:Availability CurrencyCode="USD" HotelCode="HY-CHIRC">
<ns2:GuestCount AdultCount="1" ChildCount="0"/>
<ns2:RoomTypes>
<ns2:RoomType RoomTypeCode="JRSQ" RoomTypeName="JR SUITE 2 QUEEN BEDS">
<ns2:RoomTypeDescription>Rest in sublime comfort on one of two queen signature Hyatt Grand Beds®, fitted with fine linens, down blanket and plump pillows.</ns2:RoomTypeDescription>
</ns2:RoomType>
<ns2:RoomType RoomTypeCode="CLBD" RoomTypeName="REG CLUB 2 DOUBLE BEDS">
<ns2:RoomTypeDescription>one King or two double-sized Hyatt Grand Beds, fitted with luxurious linens, a down blanket and plush pillows</ns2:RoomTypeDescription>
</ns2:RoomType>
<ns2:RoomType RoomTypeCode="VW2Q" RoomTypeName="PREMIUM VW 2 QEN">
<ns2:RoomTypeDescription>Relax and unwind in our sophisticated downtown Chicago guestrooms with city, river and lake views</ns2:RoomTypeDescription>
</ns2:RoomType>
</ns2:RoomTypes>
<ns2:RoomRates>
<ns2:RoomRate RatePlanCode="49584IPRTF" RoomTypeCode="JRSQ">
<ns2:Rates>
<ns2:Rate AmountAfterTax="523.348" AmountBeforeTax="449.650" EffectiveDate="2016-04-28" ExpireDate="2016-04-29"/>
</ns2:Rates>
<ns2:Fees>
<ns2:Fee ChargeType="Tax" Percent="16.390" Type="Exclusive"/>
</ns2:Fees>
</ns2:RoomRate>
<ns2:RoomRate RatePlanCode="49584IPRTF" RoomTypeCode="CLBD">
<ns2:Rates>
<ns2:Rate AmountAfterTax="350.218" AmountBeforeTax="300.900" EffectiveDate="2016-04-28" ExpireDate="2016-04-29"/>
</ns2:Rates>
<ns2:Fees>
<ns2:Fee ChargeType="Tax" Percent="16.390" Type="Exclusive"/>
</ns2:Fees>
</ns2:RoomRate>
<ns2:RoomRate RatePlanCode="49584IPRTF" RoomTypeCode="VW2Q">
<ns2:Rates>
<ns2:Rate AmountAfterTax="305.699" AmountBeforeTax="262.650" EffectiveDate="2016-04-28" ExpireDate="2016-04-29"/>
</ns2:Rates>
<ns2:Fees>
<ns2:Fee ChargeType="Tax" Percent="16.390" Type="Exclusive"/>
</ns2:Fees>
</ns2:RoomRate>
</ns2:RoomRates>
</ns2:Availability>
</ns2:Availabilities>
</ns2:MultiAvailabilityResponse>
</SOAP-ENV:Body>
我正在使用xmltodict库解析它。现在,我只想在我的应用程序中使用这个响应中的一些元素。我想要的元素是:RatePlanCode,RoomTypeCode,RoomTypeName,AmountBeforeTax。 另外,我想根据AmountBeforeTax对响应进行排序,并以dictionary的形式得到结果,my_dict={'roomlist':[{'RoomTypeCode':value,'RatePlanCode':vlaue,'RoomTypeName':value,'AmountBeforeTax':value}]}。你知道吗
从早上开始我就没有使用SOAP xml和敲打我的头。任何帮助都将不胜感激。谢谢!你知道吗
我不认为
xmltodict
是最好的选择。也许some other SOAP parser是一个更好的选择。你知道吗话虽如此,下面是一个基于
xmltodict
的程序,它解析上面给出的SOAP示例。你知道吗结果:
相关问题 更多 >
编程相关推荐