gatkin / declxml

Declarative XML processing for Python
https://declxml.readthedocs.io/en/latest/
MIT License
37 stars 7 forks source link

Calling `xml.serialize_to_string()` without an indent leaves out `<?xml version="1.0" encoding="utf-8"?>` #31

Open efraimbart opened 2 years ago

efraimbart commented 2 years ago

Running

import json
import declxml as xml

processor = xml.dictionary('Container', [
    xml.string('.', attribute='test')
])

container = """
{
    "test": 1
}
"""

print('Without indent:', xml.serialize_to_string(processor, json.loads(container)))
print('-----------------------------')
print('With indent', xml.serialize_to_string(processor, json.loads(container), indent='   '))

produces

Without indent: <Container test="1" />
-----------------------------
With indent <?xml version="1.0" encoding="utf-8"?>
<Container test="1"/>