I found my answer I used objectify in the lxml package
this is an example code:
from lxml import objectify root = objectify.fromstring(""" <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <a attr1="foo" attr2="bar">1</a> <a>1.2</a> <b>1</b> <b>true</b> <c>what?</c> <d xsi:nil="true"/> </root> """) print objectify.dump(root)
he prints:
root = None [ObjectifiedElement] a = 1 [IntElement] * attr1 = 'foo' * attr2 = 'bar' a = 1.2 [FloatElement] b = 1 [IntElement] b = True [BoolElement] c = 'what?' [StringElement] d = None [NoneElement] * xsi:nil = 'true'
Pooya source share