Deserialize XML to object


I am trying to deserialize xml data to objects.

For Example:



class Person:
    firstName = "John"
    lastName = "Doe"

I wanted to use the pyxser library, but I guess it’s not possible because it is not compiled (correct me if i’m wrong).
Edit: I just found out that this library is only available for python 3. Maybe you know another library :slight_smile:

pyxser-1.5.1r.tar.gz (48.5 KB)

If anyone of you has some advice I would highly appreciate it.

Best Regards,


unfortunately not, i never brought external libs to live in vc… :face_with_peeking_eye: but why not realise your stuff by using json-de/serialisation which seems to be beatiful?


1 Like

Thanks for the link captain. I will definitely use this next time, when I have the choice, but in my case I am connecting to an existing interface which uses xml.

My current alternative is using the xml library and I get each attribute individually using the find method.

import xml.etree.ElementTree as ET

personXml = ET.fromstring(data)
person = Person() 
person.firstName = personXml.find("firstname").text
person.lastName = personXml.find("lastname").text

Hy juergen,

I thought about ElementTree but throw it in the bin because there is no direct way for de/serialization… → Your solution (if no forumwonder happen :wink: ) will be make a class which wraps around ElementTree!


1 Like

Let’s hope for a wonder :wink:
But for now, I will stick to a wrapper with ElementTree.


unfortunately I think that will be the fastest way.

May the VC-pros would be able to make a instruction document how python-libs could be transformed by magic :wink: to work with VC?


1 Like