change namespace with XML.element.tree
06:04 04 Jul 2024

Working with python :
My program opens a template in XML format, insert the user info, and then saves it.

The template is the following :


    
        
        
        
        
    
    
    
  

I use xml.etree.ElementTree (and insert user data in this phase, which I skip for simplicity reasons) :

base_tree = ET.parse('XML_templates/base_structure_02.XML')
base_root = base_tree.getroot()

ET.indent(base_root,space ="    ")
xml_str = ET.tostring(base_root, encoding='unicode', method='xml')
print(xml_str)

And the output is :


    
        
        
        
        
    
    
    

The thing is that I don't want the program to get a namespace to every item (ns0), is this possible ? thank you

python xml elementtree