回复: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.