我有一个包含以下项目的列表:
poly = ['AddTicketResponse.xsd', {
'OrderServiceType': 'stPickUp',
'Taxes': {'Tax': {'Caption2': None, 'Caption': 'Sales Tax IN',
'Amount': '1.26'}},
'CreditSubtotal': '0',
'Version': '1',
'NetSubtotal': '13.97',
'CreatedTime': '2018-08-14T19:19:13Z',
'PriceGroupName': '$$Regular Price Group$$',
'PurchaseSubtotal': '13.97',
'Status': 'tsOpen',
'ItemCount': '2',
'Seq': '105651',
'Warnings': {'Warning': {'Message': 'The customer name from SpeedLine Connect differs from the name in the customer record.'
}},
'PaymentTotal': '0',
'Agent': None,
'ID': '1678'
'TaxSubtotal': '1.26',
'MenuSelections': {'MenuSelection': [{
'MenuCalculatedPriceOfAggregatedSelections': '0',
'PLU': '44'
}]}
}]
此处Poly具有两个对象:我是Poly [1],它是:
{
'OrderServiceType': 'stPickUp',
'Taxes': {'Tax': {'Caption2': None, 'Caption': 'Sales Tax IN',
'Amount': '1.26'}},
'CreditSubtotal': '0',
'Version': '1',
'NetSubtotal': '13.97',
'CreatedTime': '2018-08-14T19:19:13Z',
'PriceGroupName': '$$Regular Price Group$$',
'PurchaseSubtotal': '13.97',
'Status': 'tsOpen',
'ItemCount': '2',
'Seq': '105651',
'Warnings': {'Warning': {'Message': 'The customer name from SpeedLine Connect differs from the name in the customer record.'
}},
'PaymentTotal': '0',
'Agent': None,
'ID': '1678'
'TaxSubtotal': '1.26',
'MenuSelections': {'MenuSelection': [{
'MenuCalculatedPriceOfAggregatedSelections': '0',
'PLU': '44'
}]}
}
成为一个单独的字典,这样我就可以获取'MenuSelections'的所有值到目前为止,我仅能够将xml文件转换为列表并获得这些值。
root = ElementTree.XML(pos_xml)
xmldict = XmlDictConfig(root)
poly=[]
for key, value in xmldict.iteritems():
poly.append(value)
老实说,任何建议都会有所帮助。
ibeautiful
相关分类