I am using Python 3.2 xml.etree.ElementTreeand trying to generate XML as follows:
<XnaContent xmlns:data="Model.Data">
<Asset Type="data:MyData">
...
The format is out of my control (this is XNA). Note that the dataXML namespace is never used to qualify elements or attributes, but rather qualify attribute values for XNA. My code is as follows:
root = Element('XnaContent')
ET.register_namespace('data', 'Model.Data')
asset = SubElement(root, 'Asset', {"Type": "data:MyData"})
However, the output looks like (pretty printed by me):
<XnaContent>
<Asset Type="data:MyData">
...
</Asset>
</XnaContent>
How can I get the dataXML namespace included in the output?
source
share