Convert SGML text to dictionary.
import sgml2dict
parameter
- text: SGML text
return: dict
import sgml2dict
result = sgml2dict.convert("<hello world/></hello>")
import json
import sgml2dict
text = "<hello world/></hello>"
data = sgml2dict.convert(text)
print("Dictionary view:", data)
print("JSON view:", json.dumps(data))
Return:
Dictionary view: {'name': 'hello', 'attributes': {'world': True}}
JSON view: {"name": "hello", "attributes": {"world": true}}
https://gitlab.com/dhbmarcos/sgml2dict
- MIT License
- Copyright (c) 2023 D. H. B. Marcos. All rights reserved.