Open sanjioh opened 3 years ago
from zeep import Client
from xml.etree import ElementTree
client = Client('http://my-soap-service.example.com?wsdl')
person_type = client.get_type('Person')
person = person_type(Name='John', LastName='Doe')
person_node = ElementTree.Element('Person')
person_type.render(person_node, person)
ElementTree.tostring(person_node)
# or
person_node = ElementTree.Element('Person')
person_type.render(person_node, {
"Name": "John",
"LastName": "Doe",
})
ElementTree.tostring(person_node)
@grakic Thanks, it works perfectly!
Hi,
I need to get the XML representation of instances of (nested) complex types. I get to the point of creating the relevant objects:
What I'd like to do now is getting XML out of the
person
instance, ideally by invoking a method that returns an instance ofxml.etree.ElementTree.Element
(orlxml
's equivalent):Is there some way to get this?
Thanks!