您好,欢迎光临本网站![请登录][注册会员]  
文件名称: delphi_XML
  所属分类: Java
  开发工具:
  文件大小: 550kb
  下载次数: 0
  上传时间: 2011-01-19
  提 供 者: han****
 详细说明: 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 if lstSource.Count>0 then begin Add(''); Add('' + IntToStr(lstSource.Count) + ''); for I := 0 to lstSource.Count - 1 do begin Add(''); Add('' + IntToStr(i) + ''); Add(''+ lstSource.Items[i]+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''); end; Add(''); end else begin Add(''); Add('0'); Add(''); end; //目标字段写入XML if lstTarget.Count>0 then begin Add(''); Add('' + IntToStr(lstTarget.Count) + ''); for I := 0 to lstTarget.Count - 1 do begin Add(''); Add('' + IntToStr(i) + ''); Add(''+ lstTarget.Items[i]+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''); end; Add(''); end else begin Add(''); Add('0'); Add(''); end; Add(''); //XML注释 Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); //XML结束 end; xmlDocument.Active := True; sDir := APath; if not DirectoryExists(sDir) then begin if not CreateDir(sDir) then begin ShowMessage('创建文件夹失败'); Exit; end; end; xmlDocument.SaveToFile(sDir + 'Config.xml'); end; procedure TForm1.DeleteItem(A: TcxListBox); var _Index: Integer; begin with A do begin if (Items.Count > 0) and (ItemIndex <> -1) then begin _Index := ItemIndex; Items.Delete(_Index); end; end; end; procedure TForm1.MoveDown(A: TcxListBox); var CurrIndex, LastIndex: Integer; begin with A do begin CurrIndex := ItemIndex; LastIndex := Items.Count; if ItemIndex <> -1 then begin if CurrIndex + 1 < LastIndex then begin Items.Move(ItemIndex, (CurrIndex + 1)); ItemIndex := CurrIndex + 1; end; end; end; end; procedure TForm1.MoveUp(A: TcxListBox); var CurrIndex: Integer; begin with A do begin if ItemIndex > 0 then begin CurrIndex := ItemIndex; Items.Move(ItemIndex, (CurrIndex - 1)); ItemIndex := CurrIndex - 1; end; end; end; procedure TForm1.ReLoadItems(A: TcxListBox; const Flag: Integer); begin end; procedure TForm1.SpeedButton1Click(Sender: TObject); begin MoveDown(lstSource); end; procedure TForm1.SpeedButton2Click(Sender: TObject); begin MoveUp(lstSource); end; procedure TForm1.SpeedButton3Click(Sender: TObject); begin DeleteItem(lstSource); end; procedure TForm1.SpeedButton5Click(Sender: TObject); begin MoveDown(lstTarget); end; procedure TForm1.SpeedButton6Click(Sender: TObject); begin MoveUp(lstTarget); end; procedure TForm1.SpeedButton7Click(Sender: TObject); begin DeleteItem(lstTarget); end; end. ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: delphi_XML
 输入关键字,在本站1000多万海量源码库中尽情搜索: