uses NativeXML;
procedure TForm1.Button1Click(Sender: TObject);
var
xml: TNativeXML;
fVal: Double;
begin
fVal := 123.456789;
xml := TNativeXML.CreateName('List');
xml.XMLFormat := xfReadable;
//XML.FloatSignificantDigits := ;
with XML.Root.NodeNew('item') do begin
WriteString('Name', 'AAA');
WriteFloat('Weight', fVal);
end;
XML.FloatSignificantDigits := 5;
with XML.Root.NodeNew('item') do begin
WriteString('Name', 'BBB');
WriteFloat('Weight', fVal);
end;
XML.FloatSignificantDigits := 1;
with XML.Root.NodeNew('item') do begin
WriteString('Name', 'CCC');
WriteFloat('Weight', fVal);
end;
XML.FloatSignificantDigits := 9;
with XML.Root.NodeNew('item') do begin
WriteString('Name', 'DDD');
WriteFloat('Weight', fVal);
end;
ShowMessage(XML.Root[0][1].Value); //123.457
ShowMessage(XML.Root[1][1].Value); //123.46
ShowMessage(XML.Root[2][1].Value); //100
ShowMessage(XML.Root[3][1].Value); //123.456789
Memo1.Text := XML.WriteToString;
XML.Free;
end;
{***************************************
<?XML version="1.0" encoding="UTF-8"?>
<List>
<item>
<Name>AAA</Name>
<Weight>123.457</Weight>
</item>
<item>
<Name>BBB</Name>
<Weight>123.46</Weight>
</item>
<item>
<Name>CCC</Name>
<Weight>100</Weight>
</item>
<item>
<Name>DDD</Name>
<Weight>123.456789</Weight>
</item>
</List>
*****************************************}