• delphi xml


    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,XMLDoc,XMLIntf;
    
    type
      TForm1 = class(TForm)
        btn1: TButton;
        btn2: TButton;
        mmo1: TMemo;
        procedure btn1Click(Sender: TObject);
        procedure btn2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.btn1Click(Sender: TObject);
    var
    Xml: TXMLDocument;
    Rootnode,node : IXMLNode;
    begin
    Xml := TXMLDocument.Create(nil);
    // Xml.LoadFromFile('aaa.xml');
    try
    //加入版本信息 ‘<?xml version="1.0" encoding="GB2312" ?> ’
    Xml.Active := True;
    Xml.Version := '1.0';
    Xml.Encoding :='GB2312';
    
    Rootnode := Xml.CreateNode('CIF_INFO');
    Xml.DocumentElement := Rootnode;
    node := Xml.CreateNode('TXNCODE');
    Rootnode.ChildNodes.Add(node);
    node.Text := '420001';
    node := Xml.CreateNode('RESPCODE');
    Rootnode.ChildNodes.Add(node);
    node.Text := '0000';
    node := Xml.CreateNode('CIFID');
    Rootnode.ChildNodes.Add(node);
    node.Text := '0030209728';
    node := Xml.CreateNode('RESCODE');
    Rootnode.ChildNodes.Add(node);
    node.Text := '0000';
    node := Xml.CreateNode('RESMSG');
    Rootnode.ChildNodes.Add(node);
    node.Text := '';
    
    Xml.SaveToFile('aaa.xml');
    xml.Active := False;
    showmessage('创建成功!');
    finally
    Xml.Free;
    end;
    end;
    
    
    
    procedure TForm1.btn2Click(Sender: TObject);
    var
    Xml: TXMLDocument;
    Rootnode,node : IXMLNode;
    nodelist:IXMLNodeList;
    b,c,str :string;
    i:Integer;
    begin
    Xml := TXMLDocument.Create(Application);
    
    
    try
    Xml.LoadFromFile('aaa.xml');
    Xml.Active := True;
    
    Rootnode := Xml.DocumentElement;
    nodeList :=Rootnode.ChildNodes;
     for i:=0 to nodelist.Count-1 do
        begin
          if  Rootnode.ChildNodes[i].NodeValue = null then
             begin
               c:='';
             end
             else
             begin
               c:= Rootnode.ChildNodes[i].NodeValue;
             end;
          str:=str+c+#13#10;
        end;
    //b := Rootnode.ChildNodes[ 'CIFID'].NodeValue;
    mmo1.Lines.Add(str);
    xml.Active := False;
    finally
    Xml.Free;
    end;
    end;
    
    end.
    书搞进脑袋 创新 创造; 积极
  • 相关阅读:
    oracle 函数WMSYS.WM_CONCAT()的用法(行转列) 老猫
    PL/SQL 数独 九宫图 老猫
    oracle10g rman backup and recover 老猫
    Oracle SQL的优化 老猫
    Oracle数据库中的字符处理技巧总结 老猫
    WITH分析函数 老猫
    30套JSP网站源代码合集
    Java获取系统信息(cpu,内存,硬盘,进程等)的相关方法
    [原]Web Service学习
    常用Web Service汇总(天气预报、时刻表等)
  • 原文地址:https://www.cnblogs.com/tobetterlife/p/12171559.html
Copyright © 2020-2023  润新知