XML Binding

dieter dieter at handshake.de
Thu Sep 10 02:30:52 EDT 2015


Stefan Behnel <stefan_ml at behnel.de> writes:

> dieter schrieb am 09.09.2015 um 10:20:
>> Palpandi writes:
>>> Is it better to use pyxb than lxml?
>>>
>>> What are the advantages of lxml and pyxb?
>> 
>> "pyxb" has a different aim than "lxml".
>> 
>> "lxml" is a general purpose library to process XML documents.
>> It gives you an interface to the document's resources (elements,
>> attributes, comments, processing instructions) on a low level
>> independ from the document type.
>
> lxml's toolbox is actually larger than that. There's also lxml.objectify
> which provides a Python object interface to the XML tree, similar to what
> data binding would give you. And you can stick your own Element object
> implementations into it if you feel a need to simplify the API itself
> and/or adapt it to a given document format.
>
> http://lxml.de/objectify.html

This is nice - but still quite far from the schema support of "pyxb".

The "pyxb" binding generation generates a Python class for each type
defined in the schema. You just instantiate such a class, populate
the resulting object (in the normal Python way) and either use
it in the construction of larger objects or serialize it as XML -- no
need to worry about special construction ("objectivity.DataElement",
"objectivity.SubElement", ...), no need to worry about xml namespaces.




More information about the Python-list mailing list