Update of /cvsroot/jvcl/dev/JVCL3/examples/JvSimpleXML
In directory sc8-pr-cvs1:/tmp/cvs-serv5637/JVCL3/examples/JvSimpleXML
Added Files:
JvSimpleXMLDemo.dof JvSimpleXMLDemo.dpr JvSimpleXMLDemo.res
JvSimpleXMLDemo.zip MainFrm.dfm MainFrm.pas
Log Message:
- Copied jvcl/devtools and jvcl/examples dev/JVCL3
- Copied JVCLConvert *.dat files to dev/JVCL3/converter
--- NEW FILE: JvSimpleXMLDemo.dof ---
[Directories]
OutputDir=..\..\Bin
UnitOutputDir=..\..\Dcu
SearchPath=..\..\Source;..\..\Common
--- NEW FILE: JvSimpleXMLDemo.dpr ---
program JvSimpleXMLDemo;
uses
Forms,
MainFrm in 'MainFrm.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
--- NEW FILE: JvSimpleXMLDemo.res ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: JvSimpleXMLDemo.zip ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: MainFrm.dfm ---
object Form1: TForm1
Left = 236
Top = 107
Width = 376
Height = 329
Caption = 'JvSimpleXML Demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 12
Top = 18
Width = 40
Height = 13
Caption = '&XML file:'
end
object edXMLFile: TEdit
Left = 12
Top = 36
Width = 320
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
end
object Button1: TButton
Left = 337
Top = 36
Width = 21
Height = 21
Anchors = [akTop, akRight]
Caption = '...'
TabOrder = 1
OnClick = Button1Click
end
object JvTreeView1: TJvTreeView
Left = 12
Top = 66
Width = 344
Height = 222
Anchors = [akLeft, akTop, akRight, akBottom]
Indent = 19
TabOrder = 2
end
object JvSimpleXml1: TJvSimpleXml
Left = 102
Top = 24
end
object JvOpenDialog1: TJvOpenDialog
Filter = 'XML files|*.xml;*.xsl|All files|*.*'
Height = 347
Width = 563
Left = 154
Top = 24
end
end
--- NEW FILE: MainFrm.pas ---
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, JvEditor, StdCtrls, JvComponent, JvSimpleXml, JvDialogs,
ComCtrls, JvComCtrls;
type
TForm1 = class(TForm)
JvSimpleXml1: TJvSimpleXml;
Label1: TLabel;
edXMLFile: TEdit;
Button1: TButton;
JvOpenDialog1: TJvOpenDialog;
JvTreeView1: TJvTreeView;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure LoadFromFile(const Filename: string);
procedure ParseIntoTreeView(AnXMLNode: TJvSimpleXmlElem; ATreeNode: TTreeNode);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
JvOpenDialog1.FileName := edXMLFile.Text;
if JvOpenDialog1.Execute then
begin
LoadFromFile(JvOpenDialog1.FileName);
edXMLFile.Text := JvOpenDialog1.FileName;
end;
end;
procedure TForm1.ParseIntoTreeView(AnXMLNode: TJvSimpleXmlElem; ATreeNode: TTreeNode);
var
i, j: integer;
S, T: string;
begin
if AnXMLNode <> nil then
begin
if AnXMLNode.Value <> '' then
S := AnXMLNode.Name + '=' + AnXMLNode.Value
else
S := AnXMLNode.Name;
T := '';
for j := 0 to AnXMLNode.Properties.Count - 1 do
T := T + ' ' + AnXMLNode.Properties[j].Name + '="' + AnXMLNode.Properties[j].Value + '"';
ATreeNode := JvTreeView1.Items.AddChild(ATreeNode, S + ' (' + trim(T) + ')');
for i := 0 to AnXMLNode.Items.Count - 1 do
ParseIntoTreeView(AnXMLNode.Items[i], ATreeNode);
end;
end;
procedure TForm1.LoadFromFile(const Filename: string);
begin
Screen.Cursor := crHourGlass;
Enabled := false;
try
JvTreeView1.Items.BeginUpdate;
try
JvSimpleXML1.LoadFromFile(Filename);
JvTreeView1.Items.Clear;
ParseIntoTreeView(JvSimpleXML1.Root, JvTreeView1.Items.Add(nil, ExtractFilename(Filename)));
finally
JvTreeView1.Items.EndUpdate;
end;
JvTreeView1.FullExpand;
finally
Screen.Cursor := crDefault;
Enabled := true;
end;
end;
end.
|