It's a bit strange, but I didn't find any useful information on such (seemed) popular topic like XML serialization in Python! I'm new to Python, so forgive me dumb question in case it is. I have a class:
class Purchase:
@property
def shortPurchaseDesc(self):
return self._shortPurchaseDesc
@shortPurchaseDesc.setter
def shortPurchaseDesc(self, value):
self._shortPurchaseDesc = value;
class Result():
@property
def resultCode(self):
return self._resultCode;
@resultCode.setter
def resultCode(self, value):
self._resultCode = value
_purchase = Purchase()
@property
def purchase(self):
return self._purchase;
@purchase.setter
def purchase(self, value):
self._purchase = value
And I want to get the XML string representation of it, something like:
<result>
<resultCode>2</resultCode>
<purchase>
<shortPurchaseDesc>test</shortPurchaseDesc>
</purchase>
</result>
I've tried to use lxml.etree.tostring, but it says that Result can not be serialized. I think I'm missing something...