Created
September 6, 2025 00:13
-
-
Save dogweather/fa719ed73a1601f4a8eeb809bd6e1ba7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Convert objects to XML | |
root = ET.Element("toc") | |
for title in toc.titles: | |
title_elem = ET.SubElement(root, "title") | |
title_elem.set("number", str(title.number)) | |
title_elem.set("id", title.id) | |
title_elem.set("urn", title.urn) | |
title_elem.text = title.name | |
# Pretty print the XML | |
ET.indent(root) | |
print(ET.tostring(root, encoding='unicode')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment