Python xml marshalling

I am learning Python, my background is Java EE. I used to use JAXB, where I can basically define a regular class, throw some annotations in there, and then use JAXB to sort the objects in xml. This means that I am not involved in creating root elements, nodes, etc., but just writing a Java class and annotating it here and there. Is there something similar for Python?

+4
source share
3 answers

Here are a few:

+6
source

PyXB seems to be closest to JAXB, although I haven't used it yet. I am using lxml at the moment and believe that it works well. Amara was promising, but seemed to stagnate.

+1
source

Serialization (albeit without XML) in Python3:

 >>> import pickle >>> a=["a", "b", 234234, 55, "d"] >>> pickle.dumps(a) b'\x80\x03]q\x00(X\x01\x00\x00\x00aq\x01X\x01\x00\x00\x00bq\x02J\xfa\x92\x03\x00K7X\x01\x00\x00\x00dq\x03e.' >>> pickle.loads(pickle.dumps(a)) ['a', 'b', 234234, 55, 'd'] 
-3
source

Source: https://habr.com/ru/post/1437555/


All Articles