I am trying to create a simple XML file but I am stuck on line 3 "customer id". I cannot include spaces in the xml element but I am not sure how to write this line in Delphi.
The xml file should read as follows:
<?xml version="1.0" encoding="utf-8"?>
<data>
<customer id="123456" name="Customer X Ltd"/>
<consignment id="LX1007401911070109">
<piece>NX1007401911070109</piece>
<piece>NX1007401911070110</piece>
</consignment>
</data>
My code is as follows (exception on line 7)
myDoc := TXMLDocument.Create(Application);
myDoc.Active := true;
myDoc.Options := [doNodeAutoCreate, doNodeAutoIndent];
myDoc.Version := '1.0';
myDoc.Encoding := 'utf-8';
rootNode := MyDoc.AddChild('data', '' );
SubNode := rootnode.AddChild('consignment id', '');
The xml file should read as follows:
<?xml version="1.0" encoding="utf-8"?>
<data>
<customer id="123456" name="Customer X Ltd"/>
<consignment id="LX1007401911070109">
<piece>NX1007401911070109</piece>
<piece>NX1007401911070110</piece>
</consignment>
</data>
My code is as follows (exception on line 7)
myDoc := TXMLDocument.Create(Application);
myDoc.Active := true;
myDoc.Options := [doNodeAutoCreate, doNodeAutoIndent];
myDoc.Version := '1.0';
myDoc.Encoding := 'utf-8';
rootNode := MyDoc.AddChild('data', '' );
SubNode := rootnode.AddChild('consignment id', '');