0

I have written XML with Qdomdocument in qt application below. I want to parse it but I am keep getting this error. I cannot find any mistake from the xml. Can you please give me an advice on this?

<?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>

1 Answers1

0

XML attribute and element names cannot begin with digit characters.

Change

  • 0s="0" to something like s="0"
  • <13.7> to something like x13.7
  • etc.

in order for your XML to be well-formed.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Thanks a lot! I have spent a lot of time to figure it out. I learned a lot. – Seong Su Byeon May 06 '20 at 15:13
  • Can I ask you one short question? I want to concatenate another XML block inside this "send" element. I searched for the method but I couldn't find it. Can you give me an advice on this issue? – Seong Su Byeon May 07 '20 at 15:11
  • Be aware when combining XML files that there can only be a single root element in the resulting document. – kjhughes May 07 '20 at 15:19