Skip to content

Commit 13b0438

Browse files
Merge pull request #2 from sanjayankur31/feat/remove-spaces-in-xml-tags
feat(xml): replace spaces with underscores
2 parents 8243c01 + 7b1b570 commit 13b0438

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/modelspec/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ def build_xml_element(parent, data):
148148
if isinstance(data, dict):
149149
for key, value in data.items():
150150
if isinstance(value, dict):
151-
element = ET.SubElement(parent, key)
151+
element = ET.SubElement(parent, key.replace(" ", "_"))
152152
build_xml_element(element, value)
153153
elif isinstance(value, list):
154154
for item in value:
155-
subelement = ET.SubElement(parent, key)
155+
subelement = ET.SubElement(parent, key.replace(" ", "_"))
156156
build_xml_element(subelement, item)
157157
else:
158-
element = ET.SubElement(parent, key)
158+
element = ET.SubElement(parent, key.replace(" ", "_"))
159159
element.text = str(value)
160160
else:
161161
parent.text = str(data)

0 commit comments

Comments
 (0)