zoukankan      html  css  js  c++  java
  • 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;

  • 相关阅读:
    python 矩阵转置
    go
    Go-GRPC 初体验
    SpringMVC笔记——Spring+MyBatis组合开发简单实例
    MyBatis笔记——EhCache二级缓存
    MyBatis笔记——Mapper动态代理
    MyBatis笔记——初次环境配置
    Spring笔记——配置Hibernate框架事务
    Hibernate笔记——关联关系配置(一对多、一对一和多对多)
    Mysql笔记——触发器简单实例
  • 原文地址:https://www.cnblogs.com/zhangzhifeng/p/5420311.html
Copyright © 2011-2022 走看看