python 解析xml遇到xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 4, column 34

在调试数字驱动用xml文件的方式时,包含读取xml文件的步骤,运行程序报错:

d:\test\0629>python XmlUtil.py
Traceback (most recent call last):
  File "XmlUtil.py", line 59, in <module>
    datas = xml.getDataFromXml()
  File "XmlUtil.py", line 45, in getDataFromXml
    root = self.getRoot()
  File "XmlUtil.py", line 17, in getRoot
    tree = ElementTree.parse(self.xmlPath)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 656, in parse
    parser.feed(data)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1659, in feed
    self._raiseerror(v)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1523, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 4, column 34

xml文件是自己手动新建的,内容是自己敲上去的,对比之前的好用的xml文件的内容,并没有问题,注意力开始放在代码上了,怎么改都不行,后来几经调试,发现重新替换了xml文件就好了,文件内容检查过,并没有问题,是个奇怪的问题,目前还没有重现

先记录一下这个问题

 
posted @ 2018-06-29 18:13  夏晓旭  阅读(5975)  评论(1编辑  收藏  举报