现在我用DELPHI开发XML,但无从下手,求高手指点,或提供相关的资料。定高分相送!!
解决方案 »
- delphi调用C++的DLL问题,高手们帮帮忙,急死了
- 一个it人的困惑,希望大家给予帮助!
- 简单问题!dll怎么生成啊?
- 请问,怎样实现WINXP下的TOOLBUTTON效果(当鼠标移过去时,BUTTON突起)是用第三方控件吗?如果是在哪下载呢?如果不是,怎样才能达到那
- 如何在主窗体中用按钮控制另一个窗体的显示和定时关闭?
- 数据转换的问题?请高手指教。
- dephli的小问题?
- 问一下RECV的问题
- C/S数据库一个既简单有麻烦的问题。请求高手对我畅开心扉 ^_^ (我只有23分 7_7)
- 请问速达3000pro的报表设计器是什麽控件!
- 没分了, 还请教小弟一个问题...
- 哪位大侠有用过xpMenu
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMan, ActnMan, ActnColorMaps, CustomizeDlg, xmldom, XMLIntf,
msxmldom, XMLDoc, StdCtrls, ExtCtrls, ComCtrls;type TMainFrm = class(TForm)
XMLDocument1: TXMLDocument;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
RadioGroup1: TRadioGroup;
Button9: TButton;
Panel1: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Memo1: TMemo;
TabSheet2: TTabSheet;
TreeView1: TTreeView;
Splitter1: TSplitter;
Panel2: TPanel;
Splitter2: TSplitter;
ListBox1: TListBox;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
private
FXMLNodeName : Array of String;
Procedure InitInf;
Function ExistsXMLDoc(XMLDocValue : TXMLDocument) : Boolean;
Procedure XMLToTree(XMLDocValue : TXMLDocument);
{ Private declarations }
public
FXMLName : String;
FXMLDocument : TXMLDocument;
_RootValue : String;
//FXMLName : String;
{ Public declarations }
end;var
MainFrm: TMainFrm;implementation
uses
SetParams;{$R *.dfm}procedure TMainFrm.Button1Click(Sender: TObject);
var
vOpenDialog : TOpenDialog;
begin
vOpenDialog := TOpenDialog.Create(Nil);
vOpenDialog.Filter := 'XML文档|*.XML';
if vOpenDialog.Execute then
begin
FXMLDocument.LoadFromFile(vOpenDialog.FileName);
FXMLName := vOpenDialog.FileName;
Memo1.Lines := FXMLDocument.XML;
end;
end;procedure TMainFrm.InitInf;
begin
//..
FXMLDocument := TXMLDocument.Create(Application);
PageControl1.ActivePageIndex := 0;
end;procedure TMainFrm.FormCreate(Sender: TObject);
begin
InitInf;
end;function TMainFrm.ExistsXMLDoc(XMLDocValue: TXMLDocument): Boolean;
begin
Result := True;
if XMLDocValue.IsEmptyDoc then
Result := False;
end;procedure TMainFrm.XMLToTree(XMLDocValue: TXMLDocument);
var
Root ,iRoot,Root_ : IXMLNode;
vIndex : Integer;
TNode ,PNode , CNode : TTreeNode;
vMaxCount : Integer; //
begin
vMaxCount := 0;
Root := XMLDocValue.DocumentElement;
TNode := TreeView1.Items.AddChild(Nil,Root.DOMNode.NodeName);
{&DocumentElement: IXMLNode read GetDocumentElement write SetDocumentElement;}
iRoot := Root.ChildNodes.First;
SetLength(FXMLNodeName,iRoot.ChildNodes.Count);
while iRoot <> Nil do
begin
PNode := TreeView1.Items.AddChild(TNode,iRoot.DOMNode.NodeName);
_RootValue := iRoot.DOMNode.NodeName;
for vIndex := 0 to iRoot.ChildNodes.Count - 1 do
begin
//..
TreeView1.Items.AddChild(PNode,iRoot.ChildNodes[vIndex].Text);
if iRoot = Root.ChildNodes.First then
begin
FXMLNodeName[vIndex] := iRoot.ChildNodes[vIndex].DOMNode.NodeName;
end;
end;
iRoot := iRoot.NextSibling;
end;
end;procedure TMainFrm.RadioGroup1Click(Sender: TObject);
var
Root , iRoot : IXMLNode;
begin
PageControl1.ActivePageIndex := RadioGroup1.ItemIndex;
if Not ExistsXMLDoc(FXMLDocument) then
Exit;
if TreeView1.Items.Count = 0 then
XMLToTree(FXMLDocument) else
Exit;
end;procedure TMainFrm.Button2Click(Sender: TObject);
var
SetParamsFrm: TSetParamsFrm;
vIndex : Integer;
begin
//..
SetParamsFrm := TSetParamsFrm.Create(Application);
SetParamsFrm.ParamGrid.RowCount := High(FXMLNodeName) - Low(FXMLNodeName) + 2;
SetParamsFrm.ParamGrid.Cells[0,0] := 'Parameters';
SetParamsFrm.ParamGrid.Cells[1,0] := 'Value';
For vIndex := Low(FXMLNodeName) to High(FXMLNodeName) do
begin
SetParamsFrm.ParamGrid.Cells[0,vIndex + 1] := FXMLNodeName[vIndex];
end;
SetParamsFrm.StatuInfo.Panels[0].Text := 'Append XML Node';
SetParamsFrm.StatuInfo.Panels[1].Text := _RootValue;
SetParamsFrm.ShowModal;
end;procedure TMainFrm.Button9Click(Sender: TObject);
begin
SetParamsFrm := TSetParamsFrm.Create(Application);
SetParamsFrm.ParamGrid.RowCount := 10;
SetParamsFrm.ParamGrid.FixedCols := 0;
SetParamsFrm.ParamGrid.ColCount := 2; SetParamsFrm.ParamGrid.Cells[0,0] := 'Parameters';
SetParamsFrm.ParamGrid.Cells[1,0] := 'Value';
{For vIndex := Low(FXMLNodeName) to High(FXMLNodeName) do
begin
SetParamsFrm.ParamGrid.Cells[0,vIndex + 1] := FXMLNodeName[vIndex];
end; }
SetParamsFrm.StatuInfo.Panels[0].Text := 'New XML File';
//SetParamsFrm.StatuInfo.Panels[1].Text := _RootValue;
SetParamsFrm.ShowModal;
end;end.