Created
June 19, 2014 15:41
-
-
Save plq/11e4c28d5eeba7d145a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Foo> | |
<node_b>more_data</node_b> | |
<node_a ATTR="1st">data1</node_a> | |
<node_a ATTR="2nd">data2</node_a> | |
</Foo> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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