Python Xml解析问题:格式不正确(无效令牌)
日志文件:Python Xml解析问题:格式不正确(无效令牌),python,xml,well-formed,Python,Xml,Well Formed,日志文件: def setupDNA(self): if self.dnaStore: return None dnaFileName = self.genDNAFileName() self.dnaStore = simbase.air.loadDNA(dnaFileName) self.dnaData = self.dnaStore.generateData() self.initDNAInfo() return None fi
def setupDNA(self):
if self.dnaStore:
return None
dnaFileName = self.genDNAFileName()
self.dnaStore = simbase.air.loadDNA(dnaFileName)
self.dnaData = self.dnaStore.generateData()
self.initDNAInfo()
return None
file for the loading of the dna
def __init__(self, loader, parentFSM, doneEvent):
CogHQExterior.CogHQExterior.__init__(self, loader, parentFSM, doneEvent)
**dnaFile = 'phase_12/dna/cog_hq_bossbot_sz.xml'**
我收到以下错误消息,不知道如何消除它:
“C:\USERNAME\python\lib\xml\sax\handler.py”,第38行,在fatalError中引发异常xml.sax.\u exceptions.SAXParseException: \phase_12\dna\cog_hq_bossbot_sz.xml:6:64:格式不正确(无效 代币) XML
<?xml version="1.0" encoding="utf-8"?>
<scene zone="10000">
<store_suit_point id="1" type="STREET_POINT" x="18" y="-82" z="0.025" />
<store_suit_point id="2" type="STREET_POINT" x="62" y="-95" z="0.025" />
<store_suit_point id="3" type="STREET_POINT" x="112" y="-72" z="0.025" />
<store_suit_point id="4" type="STREET_POINT" x="128" y="-23"z="0.025" />
<store_suit_point id="5" type="STREET_POINT" x="120" y="75" z="0.025" />
<store_suit_point id="6" type="STREET_POINT" x="-9" y="84" z="0.025" />
<store_suit_point id="7" type="STREET_POINT" x="-7" y="23" z="0.025" />
<store_suit_point id="8" type="STREET_POINT" x=" 106" y="11" z=" 0.025" />
<store_suit_point id="9" type="STREET_POINT" x="80" y="-33" z="0.025" />
<store_suit_point id="10" type="STREET_POINT"x="56" y="-5" z="0.025" />
<store_suit_point id="11" type="STREET_POINT" x=" 14" y="2" z="0.025" />
<store_suit_point id="12" type="STREET_POINT" x="-23" y="-56" z="0.025" />
<group name="bossbotHQ" >
<visgroup zone= "10000" vis="10001 10002 10003 10004 10005" >
<suit_edge a="2" b="3" />
<suit_edge a="3" b="4" />
<battle_cell width="20" height="20" x="40" y="-88.5" z="0" />
</visgroup>
<visgroup zone="10001" vis="10001 10002 10003 10004 10005">
<suit_edge a="4" b="5" />
<suit_edge a="5" b="6" />
<suit_edge a="6" b="7" />
<battle_cell width="20" height="20" x="124" y="26" z="0" />
</visgroup>
<visgroup zone="10002" vis="10001 10002 10003 10004 10005">
<suit_edge a="7" b="8" />
<suit_edge a="8" b="9" />
<suit_edge a="9" b="10" />
<suit_edge a="10" b="11" />
<battle_cell width="20" height="20" x="49.5" y="17" z="0" />
</visgroup>
<visgroup zone="10003" vis="10001 10002 10003 10004 10005">
<suit_edge a="11" b="12" />
<suit_edge a="12" b="1" />
<battle_cell width="20" height="20" x="-18.5" y="-27" z="0" />
</visgroup>
<visgroup zone="10004" vis="10001 10002 10003 10004 10005">
<suit_edge a="1" b="2" />
<battle_cell width="20" height="20" x="-5" y="-71" z="0" />
</visgroup>
</group>
</scene>
另一个与加载文件相关的文件:
def setupDNA(self):
if self.dnaStore:
return None
dnaFileName = self.genDNAFileName()
self.dnaStore = simbase.air.loadDNA(dnaFileName)
self.dnaData = self.dnaStore.generateData()
self.initDNAInfo()
return None
file for the loading of the dna
def __init__(self, loader, parentFSM, doneEvent):
CogHQExterior.CogHQExterior.__init__(self, loader, parentFSM, doneEvent)
**dnaFile = 'phase_12/dna/cog_hq_bossbot_sz.xml'**
不确定这些是否都是问题,但就格式良好而言:您的
场景
-标记正在关闭
假设场景
不是组
的父级,则XML的开头应该类似于
<?xml version="1.0" encoding="utf-8"?>
<scene zone="10000">
<store_suit_point id="1" type="STREET_POINT" x="18" y="-82" z="0.025" />
<store_suit_point id="2" type="STREET_POINT" x="62" y="-95" z="0.025" />
<store_suit_point id="3" type="STREET_POINT" x="112" y="-72" z="0.025" />
<store_suit_point id="4" type="STREET_POINT" x="128" y="-23"z="0.025" />
<store_suit_point id="5" type="STREET_POINT" x="120" y="75" z="0.025" />
<store_suit_point id="6" type="STREET_POINT" x="-9" y="84" z="0.025" />
<store_suit_point id="7" type="STREET_POINT" x="-7" y="23" z="0.025" />
<store_suit_point id="8" type="STREET_POINT" x=" 106" y="11" z=" 0.025" />
<store_suit_point id="9" type="STREET_POINT" x="80" y="-33" z="0.025" />
<store_suit_point id="10" type="STREET_POINT"x="56" y="-5" z="0.025" />
<store_suit_point id="11" type="STREET_POINT" x=" 14" y="2" z="0.025" />
<store_suit_point id="12" type="STREET_POINT" x="-23" y="-56" z="0.025" />
</scene>
注意结尾的
。您的原始XML是。您更新的XML不可用
在以后添加的XML的场景
元素中,存储套件点的属性之间缺少空格
:
y="-23"z="0.025"
应该是
y="-23" z="0.025"
type="STREET_POINT" x="56"
后来又是:
type="STREET_POINT"x="56"
应该是
y="-23" z="0.025"
type="STREET_POINT" x="56"
这些错误会导致您的XML格式不正确,必须进行修复。等等,我在那里添加了它,只是没有进入那里,它在我的源代码中,虽然它在结尾。您可以提出问题并发布用于解析此文件的代码吗?您发布的XML本身格式正确。您不必泄露您的s3cret源代码,但是你必须提供代码让我们重现问题。请参阅关于如何编写一个好问题的指南。请考虑您所发布的XML可能不是解析的XML。尝试将您发布的内容粘贴回您的文件,看看是否有效。什么意思?接近那些基本上不应该在后面的东西,它实际上是一个父对象,它在文件的末尾,只是没有在oops中复制我的坏