Skip to content

Instantly share code, notes, and snippets.

@plq plq/output
Created Jun 19, 2014

Embed
What would you like to do?
<Foo>
<node_b>more_data</node_b>
<node_a ATTR="1st">data1</node_a>
<node_a ATTR="2nd">data2</node_a>
</Foo>
from spyne import *
from spyne.util.xml import get_object_as_xml
from lxml import etree
class Node(ComplexModel):
ATTR = XmlAttribute(Unicode)
data = XmlData(Unicode(max_len=450, values=['1st', '2nd']))
class Foo(ComplexModel):
node_a = Node.customize(max_occurs=2)
node_b = Unicode(max_len=450)
elt = get_object_as_xml(
Foo(
node_a=[
Node('data1', ATTR='1st'),
Node('data2', ATTR='2nd'),
],
node_b="more_data",
),
Foo
)
print(etree.tostring(elt, pretty_print=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.