6

I'm learning Python, my background is Java EE. I have used JAXB before, where I can basically define a regular class, throw some annotations in there and then use JAXB to marshall objects to xml. This means I am not concerned with creating root elements, nodes, etc. but merely writing the Java class and anotating it here and there. Is there anything like this for Python?

arg20
  • 4,893
  • 1
  • 50
  • 74
  • All (hashable) objects in Python can be serialized and there are many libraries out there that make it as easy as with Java. Are you specifically interested in XML or are other data formats okay too? – Morten Jensen Oct 03 '12 at 10:59
  • related: [XML object serialization in python, are there any alternatives to Gnosis?](http://stackoverflow.com/q/4135836/4279) – jfs Oct 03 '12 at 11:07
  • I would recommend using `lxml.objectify`. I looked into `PyXB`, which you would think would be similar to JAXB, but its documentation is pretty bad. `lxml.objectify` seems pretty good: http://lxml.de/objectify.html – James Oravec Apr 28 '15 at 00:21

2 Answers2

7

Here are a few:

Anuj Gupta
  • 10,056
  • 3
  • 28
  • 32
3

PyXB seems to be the closest thing to JAXB although I haven't used it yet. I use lxml at the moment and find it works well. Amara was promising but seemed to stagnate.

Alastair McCormack
  • 26,573
  • 8
  • 77
  • 100