{"id":18919020,"url":"https://github.com/alek-dr/xmlobj","last_synced_at":"2026-03-12T11:30:22.322Z","repository":{"id":187332338,"uuid":"676512316","full_name":"Alek-dr/xmlobj","owner":"Alek-dr","description":"xmlobj is simple utility to map xml file to python object","archived":false,"fork":false,"pushed_at":"2023-12-04T07:19:14.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T15:03:56.565Z","etag":null,"topics":["xml","xml-document","xml-parser"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alek-dr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-09T11:18:45.000Z","updated_at":"2023-08-09T20:40:55.000Z","dependencies_parsed_at":"2023-08-09T22:55:46.372Z","dependency_job_id":"2ebee704-5899-4b9c-9773-24292d97c824","html_url":"https://github.com/Alek-dr/xmlobj","commit_stats":null,"previous_names":["alek-dr/xmlobj"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alek-dr%2Fxmlobj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alek-dr%2Fxmlobj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alek-dr%2Fxmlobj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alek-dr%2Fxmlobj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alek-dr","download_url":"https://codeload.github.com/Alek-dr/xmlobj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239914942,"owners_count":19717760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["xml","xml-document","xml-parser"],"created_at":"2024-11-08T10:34:39.164Z","updated_at":"2026-03-12T11:30:22.222Z","avatar_url":"https://github.com/Alek-dr.png","language":"Python","readme":"### Description\nxmlobj is simple utility to map xml file to python object\n\nxmlobj also allows you to add functionality to mapped object by adding mixin class\n\n### A Simple Example\n```\nfrom pathlib import Path\n\nfrom PIL import Image, ImageDraw\n\nfrom xmlobj import get_xml_obj\n\n\nclass DrawBoxesMixin:\n    def draw_box(self, image) -\u003e Image.Image:\n        p1 = (self.object.bndbox.xmin, self.object.bndbox.ymin)\n        p2 = (self.object.bndbox.xmax, self.object.bndbox.ymax)\n        img_draw = ImageDraw.Draw(image)\n        img_draw.text(p1, self.object.name, align=\"left\")\n        img_draw.rectangle([p1, p2])\n        return image\n\n\nif __name__ == \"__main__\":\n    pascal_annotation = Path(\"samples/000027.xml\")\n    img_file = \"samples/000027.jpg\"\n    img = Image.open(img_file)\n    obj = get_xml_obj(pascal_annotation, mixin_clsasses=[DrawBoxesMixin])\n    rendered_img = obj.draw_box(img.copy())\n    rendered_img.show()\n\n```\n\n\n### Save xml\n```\nimport xml.etree.cElementTree as ET\n\nfrom xmlobj import get_xml_obj\n\nif __name__ == \"__main__\":\n    obj = get_xml_obj(\"samples/books.xml\")\n    root = obj.to_xml()\n    tree = ET.ElementTree(root)\n    ET.indent(tree, space=\"\\t\", level=0)\n    tree.write(\"my_xml_books.xml\")\n```\n\n### Limitations\n\n* Tag lowercase  \n\nOriginal:\n```\n  \u003cCD\u003e\n    \u003cTITLE\u003eEmpire Burlesque\u003c/TITLE\u003e\n    \u003cARTIST\u003eBob Dylan\u003c/ARTIST\u003e\n    \u003cCOUNTRY\u003eUSA\u003c/COUNTRY\u003e\n  \u003c/CD\u003e\n```\nOutput:\n```\n\u003ccd\u003e\n    \u003cTITLE\u003eEmpire Burlesque\u003c/TITLE\u003e\n    \u003cARTIST\u003eBob Dylan\u003c/ARTIST\u003e\n    \u003cCOUNTRY\u003eUSA\u003c/COUNTRY\u003e\n\u003c/cd\u003e\n```\n* Attribute properties\n\nOriginal:\n```\n \u003cbook id=\"bk101\"\u003e\n        \u003cauthor\u003eGambardella, Matthew\u003c/author\u003e\n        \u003ctitle\u003eXML Developer's Guide\u003c/title\u003e\n        \u003cgenre\u003eComputer\u003c/genre\u003e\n        \u003cprice\u003e44.95\u003c/price\u003e\n        \u003cpublish_date\u003e2000-10-01\u003c/publish_date\u003e\n        \u003cdescription\u003eAn in-depth look at creating applications\n            with XML.\n        \u003c/description\u003e\n    \u003c/book\u003e\n```\nOutput:\n```\n\u003cbook\u003e\n    \u003cid\u003ebk101\u003c/id\u003e\n    \u003cauthor\u003eGambardella, Matthew\u003c/author\u003e\n    \u003ctitle\u003eXML Developer's Guide\u003c/title\u003e\n    \u003cgenre\u003eComputer\u003c/genre\u003e\n    \u003cprice\u003e44.95\u003c/price\u003e\n    \u003cpublish_date\u003e2000-10-01\u003c/publish_date\u003e\n    \u003cdescription\u003eAn in-depth look at creating applications\n        with XML.\u003c/description\u003e\n\u003c/book\u003e\n```\n\n### Installation\n```\npip install xmlobj\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falek-dr%2Fxmlobj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falek-dr%2Fxmlobj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falek-dr%2Fxmlobj/lists"}