1/1页1 跳转到查看:3137
发新话题 回复该主题

kuku老兄,做过DELPHI读写XML的程序吗?

kuku老兄,做过DELPHI读写XML的程序吗?

kuku老兄,做过DELPHI读写XML的程序吗?
我想了解个大概,不知道是否有空帮我弄两个例子?:)

TOP

 

回复:kuku老兄,做过DELPHI读写XML的程序吗?

DELPHI里有相应的控件啊

unit Form_Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, xmldom, XMLIntf, StdCtrls, msxmldom, XMLDoc, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    SAVE_XML: TSaveDialog;
    Load_XML: TOpenDialog;
    Button2: TButton;
    TV_XML: TTreeView;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
        xml : IXMLDocument;
        iRoot : IXMLNode;
        iDoc : IXMLNode;
begin
//        xml_Manager := TXMLDocument.Create;
        if save_xml.Execute then
        begin
//              xml_manager := TXMLDocument.Create(save_xml.FileName);;
//              xml_manager.Active := true;
                xml := NewXMLDocument;
                iRoot := xml.CreateNode('TestXML');
                xml.DocumentElement := iRoot;
                iDoc := xml.CreateNode('VIN');
//                iDoc.Text := 'LL6652B047A035289';
                iDoc.Attributes['id'] := 1;
                iDoc.Attributes['流水号位数'] := 5;
                iDoc.Attributes['内容'] := 'LL6652B047A035289';
                xml.DocumentElement.ChildNodes.Add( iDoc );
                xml.SaveToFile( save_xml.FileName );
        end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
        xml : IXMLDocument;
        iNode : IXMLNode;
        iList : IXMLNodeList;
        m_str : string;
begin
        if load_xml.Execute then
        begin
                xml := TXMLDocument.Create(nil);
                xml.LoadFromFile( load_xml.FileName );
//                showmessage(inttostr(xml.ChildNodes.Count));
//                iNode := xml.ChildNodes.Nodes[1];
//                iNode := xml.ChildNodes
//                m_str := iNode.Attributes[];
        end;
end;

end.


TOP

 

回复:kuku老兄,做过DELPHI读写XML的程序吗?

阅过了,谢谢老兄啦!~

TOP

 

回复:kuku老兄,做过DELPHI读写XML的程序吗?

这个本来就是测试工程 代码没写完 也没有读取后的处理。。

TOP

 
1/1页1 跳转到
发表新主题 回复该主题