Given a PyXB object, how can one turn it into a string?
I used PyXB to generate an XML document, which I would like to then turn into a dictionary using the xmltodict module. The issue is that xmltodict.parse takes a bytes-like object, which the PyXB object of course, is not.
I found a method in the python d1_python library that accomplishes this. The method takes a
PyXBobject and will serialize it with the given encoding.As an example, you can parse a
PyXBobject to UTF-8 withserialize_gen(pyxb_object, utf-8)To convert the object to a string, it would be called as
serialize_gen(pyxb_object, None)