7

I need to serialize my Python objects into XML data. I tried to use Django, but it only works for QuerySet objects and not for any simple Python object.

How can I serialize a Python object into XML data?

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Wasim
  • 1,915
  • 5
  • 24
  • 39
  • Possible duplicate of [How can I change a Python object into XML?](https://stackoverflow.com/questions/3334446/how-can-i-change-a-python-object-into-xml) – Stevoisiak Feb 13 '18 at 20:53

2 Answers2

3

http://freshmeat.net/projects/gnosisxml/

darelf
  • 4,589
  • 2
  • 16
  • 11
  • Thanks you very much, By noticed it serialize Python based objects (list , int ...) When I give it my custom objects it doesn't serialize it. Any help Thanks... – Wasim Jan 24 '10 at 10:25
  • Hi , Thanks , it now works perfectly. But , I see that the dumps output many attributes I don't really want or don't want to return them to the client to save traffic , like id , module, familly and type. Do you know a way to drop them. Thanks... – Wasim Jan 28 '10 at 10:41
  • 1
    This answer should include more details, as [it is currently a link-only answer](https://meta.stackexchange.com/q/225370/351462). – Stevoisiak Feb 13 '18 at 15:04
  • 1
    For any recent readers, gnosis is *long* out of date. I couldn't even install it without messing with its `setup.py`, and then it failed to parse certain things, looking for object properties that no longer exist in the language – Pavel Komarov Mar 19 '18 at 17:26
3

You could also have a look at the objectify module from lxml.

botchniaque
  • 4,698
  • 3
  • 35
  • 63
jkp
  • 78,960
  • 28
  • 103
  • 104