I'm using Python LXML etree to parse XML addenda and I need to get rid of ns0 NAMESPACE
I already tried the solution described in the link below but did not get the result I'm looking for.
Remove namespace and prefix from xml in python using lxml
My code is like this:
from lxml import etree, objectify
tree = etree.parse(TEMPdir+FILEname)
addendaData = tree.getroot()
cfdi = "cfdi" #"http://www.sat.gob.mx/cfd/3"
dsf = "http://tempuri.org/DSFactura.xsd"
ns3 = {"dsf": dsf}
addenda = etree.SubElement(addendaData, "{" + cfdi + "}" + "Addenda",)
cargaRemision = etree.SubElement(addenda, "DSCargaRemisionProv",
nsmap = ns3
)
With this code I'm getting XML:
...
<ns0:Addenda xmlns:ns0="http://www.sat.gob.mx/cfd/3">
<DSCargaRemisionProv xmlns:dsf="http://tempuri.org/DSFactura.xsd">
<Remision ...>
</DSCargaRemisionProv>
</ns0:Addenda>
And what I need to get is this:
...
<cfdi:Addenda>
<DSCargaRemisionProv xmlns:dsf="http://tempuri.org/DSFactura.xsd">
<Remision ...>
</DSCargaRemisionProv>
</cfdi:Addenda>