Saving XML files using ElementTree

前端 未结 4 996
南笙
南笙 2020-11-30 06:28

I\'m trying to develop simple Python (3.2) code to read XML files, do some corrections and store them back. However, during the storage step ElementTree adds this n

4条回答
  •  囚心锁ツ
    2020-11-30 06:51

    It seems that you have to declare your namespace, meaning that you need to change the first line of your xml from:

    
    

    to something like:

    
    

    Once did that you will no longer get ParseError: for unbound prefix: ..., and:

    elem.tag = elem.tag[(len('{uri:}'):]
    

    will remove the namespace.

提交回复
热议问题