OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Force python to write namespace in root tag

  • Thread starter Thread starter principal-ideal-domain
  • Start date Start date
P

principal-ideal-domain

Guest
I'm using python to generate an XML document for a third party. The third party has very precise ideas about how the final xml file shall look like. In my case it wants me to define a namespace in the root tag which is never used in the document. The ET.ElementTree.write method is quite smart and defines only namespaces in the root tag which are used in the document. Is there a way to overcome its smartness and force it to write another additional namespace in the root tag?

The respective attribute in the root tag shall look like that:

Code:
xmlns:SPECIAL_NAMESPACE="NAMESPACE_URL"
<p>I'm using python to generate an XML document for a third party. The third party has very precise ideas about how the final xml file shall look like. In my case it wants me to define a namespace in the root tag which is never used in the document. The
<code>ET.ElementTree.write</code> method is quite smart and defines only namespaces in the root tag which are used in the document. Is there a way to overcome its smartness and force it to write another additional namespace in the root tag?</p>
<p>The respective attribute in the root tag shall look like that:</p>
<pre><code>xmlns:SPECIAL_NAMESPACE="NAMESPACE_URL"
</code></pre>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top