I'm trying to add namespaces in a xml that I'm generating so I tried this and came up with the code below:
from xml.etree import ElementTree as ET
NS1 = "http://www.w3.org/"
ET.register_namespace("xsi", NS1)
qname1 = ET.QName(NS1, "D") # Element QName
root = ET.Element("Database", {qname1:""},xmlns="http://www.staubli.com/")
print(ET.tostring(root).decode())
This code gives me
<Database xmlns:xsi="http://www.w3.org/" xsi:D="" xmlns="http://www.staubli.com/" />
And i want
<Database xmlns:xsi="http://www.w3.org/" xmlns="http://www.staubli.com/">
So I want to get rid of the xsi:D=""
. But if I remove the "D" from my QName line, all the namespaces disappear.
Do you know how I can achieve this? Thank you.