Python Zeep XML - 0 float value changes type shape

19 Views Asked by At

I have a simple type in a XSD

<xs:element name="RateByRoom">
    <xs:complexType>
        <xs:choice>
            <xs:element name="BuyingPrice" type="xs:double"/>
            <xs:element name="SellingPrice" type="xs:double"/>
        </xs:choice>
    </xs:complexType>
</xs:element>

but when I parse

<HostingRate hosting_type_code="TEST_01:01">
    <RateByRoom>
      <BuyingPrice>0.0</BuyingPrice>
   </RateByRoom>
</HostingRate>

I get

{
    'hosting_type_code': 'TEST_01:01',
    'length_of_stay': None
}

Do you think it's an issue specific to my project, or there is something about this I missed in the doc?

If I change the 0.0 in a 1.0, I get

{
    'hosting_type_code': 'TEST_01:01',
    'length_of_stay': None,
    'RateByRoom': {
        'BuyingPrice': 1.0,
        'SellingPrice': None
    },
    'RatesByPax': None,
    'RatesByOccupancy': None
}

Edit: For parsing, I use the following:

response_element: lxml.etree._Element = ...
InventoryUpdate = broker_client.zeep_client.get_element("ns0:InventoryUpdate")
inventory_update = InventoryUpdate.parse(response_element, zeep_client)

In this case, InventoryUpdate is a high level return type in the WSDL. Then I access elements using the zeep API (attribute or dict syntax), HostingRate is somewhere is the tree.

0

There are 0 best solutions below