为什么在xml解析过程中出现“格式不正确(无效令牌):第10行第20列”错误

2024-09-30 22:22:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经在下面的qt应用程序中用Qdomdocument编写了XML。 我想分析它,但我一直得到这个错误。我从xml中找不到任何错误。你能给我一个建议吗

<?xml version='1.0' encoding='UTF-8'?>
<send>
 <heartbeat>
  <NumberOfOwnships>1</NumberOfOwnships>
  <NumberOfTrafficShips>0</NumberOfTrafficShips>
  <NumberOfTugs>0</NumberOfTugs>
  <SimulationRunningStatus>0</SimulationRunningStatus>
  <SimulationTime>0</SimulationTime>
 </heartbeat>
 <elem nr="0" 0s="0" id="OS_Name" no="0" ts="0">
  <name>seongsu</name>
 </elem>
 <elem nr="0" 0s="0" id="OS_CourseOverGround" no="0" ts="0">
  <courseOverGround>1.2</courseOverGround>
 </elem>
 <elem nr="0" 0s="0" id="OS_Latitude" no="0" ts="0">
  <latitude>13.5</latitude>
 </elem>
 <elem nr="0" 0s="0" id="Longitude" no="0" ts="0">
  <Longitude>13.7</Longitude>
 </elem>
 <elem nr="0" 0s="0" id="OS_SpeedOverGround" no="0" ts="0">
  <u>1</u>
 </elem>
 <elem nr="0" 0s="0" id="OS_RateOfTurn" no="0" ts="0">
  <rateOfTurn>1</rateOfTurn>
 </elem>
 <elem nr="0" 0s="0" id="OS_Heading" no="0" ts="0">
  <Heading>1</Heading>
 </elem>
 <elem nr="0" 0s="0" id="OS_Length" no="0" ts="0">
  <length>200</length>
 </elem>
 <elem nr="0" 0s="0" id="OS_Width" no="0" ts="0">
  <width>100</width>
 </elem>
</send>

Tags: nosendidos错误xmlnrts
1条回答
网友
1楼 · 发布于 2024-09-30 22:22:49

XML属性和元素名称不能以数字字符开头

改变

  • 0s="0"到类似s="0"
  • <13.7>到类似x13.7
  • 等等

为了使您的XML成为well-formed

相关问题 更多 >