I'm constructing a dictionary with Python to use with a SOAP API.
My SOAP API takes an input like this:
<dataArray><AccountingYearData><Handle><Year>string</Year></Handle><Year>string</Year><FromDate>dateTime</FromDate><ToDate>dateTime</ToDate><IsClosed>boolean</IsClosed></AccountingYearData><AccountingYearData><Handle><Year>string</Year></Handle><Year>string</Year><FromDate>dateTime</FromDate><ToDate>dateTime</ToDate><IsClosed>boolean</IsClosed></AccountingYearData>
</dataArray>
Se this for the full string https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=AccountingYear_CreateFromDataArray
Notice how the field appears multiple times.
How can I create a Python dict with this data?
If I do this:
data = {'dataArray':{'AccountingYearData':{'Handle':{'Year':'2017'}, 'Year':'2017','FromDate':'2017-01-01', 'ToDate':'2017-12-31', 'IsClosed':'False'},'AccountingYearData':{'Handle':{'Year':'2017'}, 'Year':'2017','FromDate':'2017-01-01', 'ToDate':'2017-12-31', 'IsClosed':'False'}}
}
I get:
>>> type (data)
<type 'dict'>
>>> data {'dataArray': {'AccountingYearData': {'IsClosed': 'False', 'FromDate': '2017-01-01', 'Handle': {'Year': '2017'}, 'ToDate': '2017-12-31', 'Year': '2017'}}
}
It's as expected I think, but now what I need.