I am using lxml to generate a xml file.
from lxml import etree as ET
I register a namespace using this line
ET.register_namespace("exp", "http://ift.tt/YEC8oG")
If I add an element with
root_exp = ET.Element("{http://ift.tt/1DQnn2Y")
or an SubElement with
foo_hdr = ET.SubElement(root_exp, "{http://ift.tt/YEC9sE")
the namespace is defined every time the namespace appears, e.g.
<exp:bar xmlns:exp="http://ift.tt/YEC8oG">
<exp:fooHdr CREATEDATE="2013-03-22T10:28:27.137531">
This is well-formed XML afaik, but I think this is not necessary and it looks very verbose. How can this behaviour be suppressed? There should be one definition for each namespace in the header of the xml file.
Thanks in advance!
No comments:
Post a Comment