Skip to content

Commit a4f4b6e

Browse files
committed
IMP Allow xml as str in lists for building
1 parent c1c2f02 commit a4f4b6e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libcomxml/core/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def build_tree(self):
235235
continue
236236
self.doc_root.append(field.doc_root)
237237
elif isinstance(field, list):
238-
# we just allow XmlFields and XmlModels in the list
238+
# we just allow XmlFields and XmlModels
239+
# Also xml as str for memory management
239240
for item in field:
240241
if isinstance(item, XmlField):
241242
ele = item.element()
@@ -247,6 +248,9 @@ def build_tree(self):
247248
if self.drop_empty and len(item.doc_root) == 0:
248249
continue
249250
self.doc_root.append(item.doc_root)
251+
elif isinstance(item, str):
252+
ele = etree.fromstring(item)
253+
self.doc_root.append(ele)
250254
item = None
251255
elif (field.parent or self.root.name) == self.root.name:
252256
ele = field.element()

0 commit comments

Comments
 (0)