Here's some code I found to strip namespaces after parsing, without relying on a regex:
``` # Remove namespace prefixes #Source: https://stackoverflow.com/questions/60486563/ tree = et.parse(INPUTFILE) root = tree.getroot() for elem in root.getiterator(): #ValueError: Invalid input tag of type <class 'cython_function_or_method'> #et.tag = et.QName(elem).localname # For elements, replace qualified name with localname if not(type(elem) == et._Comment): elem.tag = et.QName(elem).localname # Remove attributes that are in a namespace for attr in elem.attrib: if "{" in attr: elem.attrib.pop(attr) # Remove unused namespace declarations et.cleanup_namespaces(root) ``` _______________________________________________ lxml - The Python XML Toolkit mailing list -- lxml@python.org To unsubscribe send an email to lxml-le...@python.org https://mail.python.org/mailman3/lists/lxml.python.org/ Member address: arch...@mail-archive.com