文件名称:delphi_XML
文件大小:550KB
文件格式:RAR
更新时间:2014-02-08 08:56:15
delphi_XML
unit XMLexample;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, StdCtrls, Buttons,
cxContainer, cxListBox, msxmldom, XMLDoc;
type
TForm1 = class(TForm)
XMLDocument1: TXMLDocument;
lstSource: TcxListBox;
lstTarget: TcxListBox;
SpeedButton2: TSpeedButton;
SpeedButton1: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
Button1: TButton;
cxListBox1: TcxListBox;
cxListBox2: TcxListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
private
{ Private declarations }
public
procedure MoveUp(A: TcxListBox); //上移
procedure MoveDown(A: TcxListBox); //下移
procedure DeleteItem(A: TcxListBox); //删除
procedure ReLoadItems(A: TcxListBox; const Flag: Integer = 0); //重置
procedure CreateXML(APath:string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateXML('C:\Documents and Settings\Administrator\桌面\XML');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Node: IXMLNode;
Root: IXMLNode; //根节点
ParentNode: IXMLNode; //首节点
StrDir: string;
xmlDocument: IXMLDocument;
I: Integer;
begin
xmlDocument := TXMLDocument.Create(nil);
StrDir := 'C:\Documents and Settings\Administrator\桌面\XMLConfig.xml';
xmlDocument.XML.LoadFromFile(StrDir);
xmlDocument.Active := true;
Root := xmlDocument.DocumentElement;
//源字段
ParentNode:=Root.ChildNodes.FindNode('FieldsFromSource');
for I := 1 to ParentNode.ChildNodes.Count - 1 do
begin
Node:=ParentNode.ChildNodes[i];
cxListBox1.Items.Add(Node.ChildValues['FieldName']);
end;
//目标字段
ParentNode:=Root.ChildNodes.FindNode('FieldsFromTarget');
for I := 1 to ParentNode.ChildNodes.Count - 1 do
begin
Node:=ParentNode.ChildNodes[i];
cxListBox2.Items.Add(Node.ChildValues['FieldName']);
end;
end;
procedure TForm1.CreateXML(APath: string);
var
xmlDocument: IXMLDocument;
sDir: string;
i:Integer;
begin
xmlDocument := TXMLDocument.Create(nil);
with xmlDocument.XML do
begin
//开始写XML
Add('');
Add('
【文件预览】:
XML
----__history()
--------XMLexample.pas.~49~(6KB)
--------XMLexample.pas.~48~(5KB)
--------XMLexample.pas.~50~(6KB)
--------XMLexample.dfm.~7~(3KB)
--------XMLexample.pas.~47~(5KB)
--------XMLexample.dfm.~1~(334B)
--------XMLexample.pas.~53~(7KB)
--------XMLexample.pas.~54~(7KB)
--------XMLexample.pas.~51~(6KB)
--------XMLexample.dfm.~6~(3KB)
--------XMLexample.pas.~55~(7KB)
--------XMLexample.dfm.~3~(3KB)
--------XMLexample.dfm.~8~(3KB)
--------XMLexample.pas.~52~(6KB)
--------XMLexample.dfm.~4~(3KB)
--------XMLexample.dfm.~10~(3KB)
--------XMLexample.dfm.~9~(3KB)
--------XMLexample.pas.~46~(5KB)
--------XMLexample.dfm.~5~(3KB)
--------XMLexample.dfm.~2~(2KB)
----XMLexample.dfm(3KB)
----XML.res(5KB)
----XML.identcache(205B)
----XML.dpr(235B)
----XML.dproj(4KB)
----XML.exe(1.19MB)
----XMLexample.pas(7KB)
----XMLexample.dcu(12KB)
----XML.dproj.local(824B)