delphi TClientDataSet 保存到XML

procedure ExPortNodeQuantifyComponent1(aCDS: TClientDataSet; aCurrNode: TXMLNode);
var
mStream: TMemoryStream;
I: Integer;
vNode: TcxTreeListNode;
NativeXml: TNativeXml;
vXMLNode, rootNode: TXmlNode;
begin
mStream:=TMemoryStream.Create;
NativeXml := TNativeXml.CreateName('aaa');
try
NativeXml.EncodingString := 'UTF-8';
NativeXml.Utf8Convert := True;
NativeXml.XmlFormat := xfReadable;
NativeXml.BinaryEncoding := xbeBinHex;
// rootNode := NativeXml.Root;
for I := 0 to SGrid_QuantifyList.Count -1 do
begin
vNode := SGrid_QuantifyList.Items[I];
aCDS.Append;
aCDS.FieldByName('cSetOfPeakTime').AsString := vNode.Texts[colcom_cSetOfPeakTime.ItemIndex];
aCDS.FieldByName('cComponentName').AsString := vNode.Texts[colcom_cComponentName.ItemIndex];
aCDS.FieldByName('cComponentNumber').AsString := vNode.Texts[colcom_cComponentNumber.ItemIndex];
aCDS.FieldByName('cCorrectionFactor').AsString := vNode.Texts[colcom_cCorrectionFactor.ItemIndex];
aCDS.FieldByName('cConcentration').AsString := vNode.Texts[colcom_cConcentration.ItemIndex];
aCDS.FieldByName('cInteriorLabel').AsString := vNode.Texts[colcom_cInteriorLabel.ItemIndex];
aCDS.FieldByName('cPeakStart').AsString := vNode.Texts[colcom_cPeakStart.ItemIndex];
aCDS.FieldByName('cPeakEnd').AsString := vNode.Texts[colcom_cPeakEnd.ItemIndex];
aCDS.FieldByName('cGroupTotal').AsString := vNode.Texts[colcom_cGroupTotal.ItemIndex];
aCDS.FieldByName('iid').AsString := vNode.Texts[colcom_iid.ItemIndex];
aCDS.FieldByName('cGroupID').AsString := vNode.Texts[colcom_cGroupID.ItemIndex];
aCDS.FieldByName('cTheSameBatchID').AsString := vNode.Texts[colcom_cTheSameBatchID.ItemIndex];

aCDS.Post;
vXMLNode := aCurrNode.NodeNew('aaa' + IntToStr(I)) ;
vXMLNode.WriteAttributeString('cSetOfPeakTime', vNode.Texts[colcom_cSetOfPeakTime.ItemIndex]);
vXMLNode.WriteAttributeString('cComponentName', vNode.Texts[colcom_cComponentName.ItemIndex]);
vXMLNode.WriteAttributeString('cComponentNumber', vNode.Texts[colcom_cComponentNumber.ItemIndex]);
vXMLNode.WriteAttributeString('cCorrectionFactor', vNode.Texts[colcom_cCorrectionFactor.ItemIndex]);
vXMLNode.WriteAttributeString('cConcentration', vNode.Texts[colcom_cConcentration.ItemIndex]);
vXMLNode.WriteAttributeString('cInteriorLabel', vNode.Texts[colcom_cInteriorLabel.ItemIndex]);
vXMLNode.WriteAttributeString('cPeakStart', vNode.Texts[colcom_cPeakStart.ItemIndex]);
vXMLNode.WriteAttributeString('cPeakEnd', vNode.Texts[colcom_cPeakEnd.ItemIndex]);
vXMLNode.WriteAttributeString('cGroupTotal', vNode.Texts[colcom_cGroupTotal.ItemIndex]);
vXMLNode.WriteAttributeString('iid', vNode.Texts[colcom_iid.ItemIndex]);
vXMLNode.WriteAttributeString('cGroupID', vNode.Texts[colcom_cGroupID.ItemIndex]);
vXMLNode.WriteAttributeString('cTheSameBatchID', vNode.Texts[colcom_cTheSameBatchID.ItemIndex]);
end;
NativeXml.SaveToFile('C:\111.xml');
aCDS.DisableControls;
mStream.Clear;
if not aCDS.IsEmpty then
begin
aCDS.SaveToStream(mStream);
//XmlWriteStream(aCurrNode,CH_QuantifyComponentChildNode,mStream);
end;
aCDS.EnableControls;
finally
mStream.Free;
NativeXml.Free;
end;
end;

上一篇:使用JSPatch平台热修复iosApp


下一篇:外网ssh内网Linux服务器holer实现