@@ 88-102 (lines=15) @@ | ||
85 | father.appendChild(tag) |
|
86 | self.build(tag, structure[k]) |
|
87 | ||
88 | elif type(structure) == list: |
|
89 | grand_father = father.parentNode |
|
90 | tag_name = father.tagName |
|
91 | grand_father.removeChild(father) |
|
92 | for l in structure: |
|
93 | tag = self.doc.createElement(tag_name) |
|
94 | self.build(tag, l) |
|
95 | grand_father.appendChild(tag) |
|
96 | else: |
|
97 | if type(structure) == unicode: |
|
98 | data = structure.encode("ascii", errors="xmlcharrefreplace") |
|
99 | else: |
|
100 | data = str(structure) |
|
101 | tag = self.doc.createTextNode(data) |
|
102 | father.appendChild(tag) |
|
103 | ||
104 | def __str__(self): |
|
105 | return self.doc.toprettyxml(indent=" ") |
@@ 79-91 (lines=13) @@ | ||
76 | tag = xml.createElement(tag_name) |
|
77 | _parse_xml_element(xml, tag, l) |
|
78 | father.appendChild(tag) |
|
79 | elif type(structure) == set: |
|
80 | tag_name = father.tagName |
|
81 | for l in list(structure): |
|
82 | tag = xml.createElement(tag_name) |
|
83 | _parse_xml_element(xml, tag, l) |
|
84 | father.appendChild(tag) |
|
85 | else: |
|
86 | if type(structure) == unicode: |
|
87 | data = structure.encode("ascii", errors="xmlcharrefreplace") |
|
88 | else: |
|
89 | data = str(structure) |
|
90 | tag = xml.createTextNode(data) |
|
91 | father.appendChild(tag) |
|
92 | ||
93 | ||
94 | def export_xml(model, filename, fields=None): |