demo: add xml reader demo from Aleksey Lagunov

git-svn-id: trunk@22889 -
This commit is contained in:
paul 2009-12-01 10:06:49 +00:00
parent a9f222d1e9
commit 3a3cc91bd0
10 changed files with 5820 additions and 0 deletions

9
.gitattributes vendored
View File

@ -3156,6 +3156,15 @@ examples/widestringstreaming/mainunit.lrs svneol=native#text/pascal
examples/widestringstreaming/mainunit.pas svneol=native#text/plain
examples/widestringstreaming/widestringstreaming.lpi svneol=native#text/plain
examples/widestringstreaming/widestringstreaming.lpr svneol=native#text/plain
examples/xmlreader/TestXMLReder.ico -text svneol=unset#image/ico
examples/xmlreader/TestXMLReder.lpi svneol=native#text/plain
examples/xmlreader/TestXMLReder.lpr svneol=native#text/plain
examples/xmlreader/TestXMLReder.lrs svneol=native#text/plain
examples/xmlreader/TestXMLReder.manifest svneol=native#text/plain
examples/xmlreader/TestXMLReder.rc svneol=native#text/plain
examples/xmlreader/testxmlreaderunit.lfm svneol=native#text/plain
examples/xmlreader/testxmlreaderunit.lrs svneol=native#text/plain
examples/xmlreader/testxmlreaderunit.pas svneol=native#text/plain
examples/xmlstreaming/mainunit.lfm svneol=native#text/plain
examples/xmlstreaming/mainunit.lrs svneol=native#text/pascal
examples/xmlstreaming/mainunit.pas svneol=native#text/plain

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,132 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Title Value="TestXMLReder"/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="/home/alexs/work/fpc/demo10-xml/TestXMLReder.lpi"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="6">
<Unit0>
<Filename Value="TestXMLReder.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TestXMLReder"/>
<UsageCount Value="21"/>
</Unit0>
<Unit1>
<Filename Value="testxmlreaderunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="XMLRederForm"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="TestXMLReaderUnit"/>
<CursorPos X="1" Y="135"/>
<TopLine Value="101"/>
<EditorIndex Value="0"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../../install/fpcsrc/packages/fcl-xml/src/xmlread.pp"/>
<UnitName Value="XMLRead"/>
<CursorPos X="11" Y="3800"/>
<TopLine Value="3782"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<Filename Value="../../../install/fpcsrc/packages/fcl-xml/src/dom.pp"/>
<UnitName Value="DOM"/>
<CursorPos X="3" Y="947"/>
<TopLine Value="945"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="../../../../../usr/local/share/lazarus/lcl/comctrls.pp"/>
<UnitName Value="ComCtrls"/>
<CursorPos X="28" Y="829"/>
<TopLine Value="811"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="../../../../../usr/local/share/lazarus/lcl/interfaces/gtk/gtkwidgetset.inc"/>
<CursorPos X="59" Y="4318"/>
<TopLine Value="4300"/>
<UsageCount Value="10"/>
</Unit5>
</Units>
<JumpHistory Count="3" HistoryIndex="2">
<Position1>
<Filename Value="testxmlreaderunit.pas"/>
<Caret Line="91" Column="53" TopLine="31"/>
</Position1>
<Position2>
<Filename Value="testxmlreaderunit.pas"/>
<Caret Line="124" Column="7" TopLine="92"/>
</Position2>
<Position3>
<Filename Value="testxmlreaderunit.pas"/>
<Caret Line="69" Column="28" TopLine="34"/>
</Position3>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<Target>
<Filename Value="TestXMLReder"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program TestXMLReder;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, TestXMLReaderUnit, LResources
{ you can add units after this };
{$IFDEF WINDOWS}{$R TestXMLReder.rc}{$ENDIF}
begin
{$I TestXMLReder.lrs}
Application.Initialize;
Application.CreateForm(TXMLRederForm, XMLRederForm);
Application.Run;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="CompanyName.ProductName.YourApp" type="win32"/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,7 @@
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "TestXMLReder.manifest"
MAINICON ICON "TestXMLReder.ico"

View File

@ -0,0 +1,191 @@
object XMLRederForm: TXMLRederForm
Left = 312
Height = 690
Top = 119
Width = 939
ActiveControl = Panel1
Caption = 'XML reader test'
ClientHeight = 690
ClientWidth = 939
OnClose = FormClose
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.29'
object TreeView1: TTreeView
Left = 0
Height = 624
Top = 66
Width = 457
Align = alLeft
AutoExpand = True
DefaultItemHeight = 19
ReadOnly = True
TabOrder = 0
OnClick = TreeView1Click
Options = [tvoAutoExpand, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
object Panel1: TPanel
Left = 0
Height = 66
Top = 0
Width = 939
Align = alTop
AutoSize = True
ClientHeight = 66
ClientWidth = 939
TabOrder = 1
object BitBtn1: TBitBtn
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 867
Height = 30
Top = 30
Width = 66
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Load'
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000000000000000000000000000000000000000000000000
8000008000000080800080000000800080008080000080808000C0C0C0000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00EEEEEEEEEEEE
EEEEEE000000EEEEEEEEEEEEEEEEEE000000EE00000000000EEEEE000000EE00
3333333330EEEE000000EE0B03333333330EEE000000EE0FB03333333330EE00
0000EE0BFB03333333330E000000EE0FBFB00000000000000000EE0BFBFBFBFB
0EEEEE000000EE0FBFBFBFBF0EEEEE000000EE0BFB0000000EEEEE000000EEE0
00EEEEEEEE000E000000EEEEEEEEEEEEEEE00E000000EEEEEEEEEE0EEE0E0E00
0000EEEEEEEEEEE000EEEE000000EEEEEEEEEEEEEEEEEE000000EEEEEEEEEEEE
EEEEEE000000EEEEEEEEEEEEEEEEEE000000
}
OnClick = BitBtn1Click
TabOrder = 0
end
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 6
Height = 18
Top = 6
Width = 66
BorderSpacing.Around = 6
Caption = 'File name'
ParentColor = False
end
object FileNameEdit1: TFileNameEdit
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
Left = 12
Height = 29
Top = 30
Width = 828
FileName = '/home/alexs/work/a/2009-11-24/Magazin_7_RealizaciqTovarovUslug_2009-11-11.xml'
DialogOptions = []
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 0
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
MaxLength = 0
TabOrder = 1
end
end
object Splitter1: TSplitter
Left = 457
Height = 624
Top = 66
Width = 5
end
object Panel2: TPanel
Left = 462
Height = 624
Top = 66
Width = 477
Align = alClient
Caption = 'Panel2'
ClientHeight = 624
ClientWidth = 477
TabOrder = 3
object ListView1: TListView
AnchorSideTop.Control = Edit2
AnchorSideTop.Side = asrBottom
Left = 1
Height = 499
Top = 124
Width = 475
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
Columns = <
item
Caption = 'Name'
Width = 100
end
item
Caption = 'Value'
Width = 350
end>
TabOrder = 0
ViewStyle = vsReport
end
object Label2: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
Left = 6
Height = 18
Top = 6
Width = 81
BorderSpacing.Around = 6
Caption = 'Node name'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Edit1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 18
Top = 65
Width = 78
BorderSpacing.Around = 6
Caption = 'Node value'
ParentColor = False
end
object Edit1: TEdit
AnchorSideLeft.Control = Label2
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 12
Height = 29
Top = 30
Width = 459
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabOrder = 1
Text = 'Edit1'
end
object Edit2: TEdit
AnchorSideLeft.Control = Label3
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 12
Height = 29
Top = 89
Width = 459
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabOrder = 2
Text = 'Edit2'
end
end
end

View File

@ -0,0 +1,71 @@
{ Это - файл ресурсов, автоматически созданный lazarus }
LazarusResources.Add('TXMLRederForm','FORMDATA',[
'TPF0'#13'TXMLRederForm'#12'XMLRederForm'#4'Left'#3'8'#1#6'Height'#3#178#2#3
+'Top'#2'w'#5'Width'#3#171#3#13'ActiveControl'#7#6'Panel1'#7'Caption'#6#15'XM'
+'L reader test'#12'ClientHeight'#3#178#2#11'ClientWidth'#3#171#3#7'OnClose'#7
+#9'FormClose'#8'OnCreate'#7#10'FormCreate'#8'Position'#7#14'poScreenCenter'
+#10'LCLVersion'#6#6'0.9.29'#0#9'TTreeView'#9'TreeView1'#4'Left'#2#0#6'Height'
+#3'p'#2#3'Top'#2'B'#5'Width'#3#201#1#5'Align'#7#6'alLeft'#10'AutoExpand'#9#17
+'DefaultItemHeight'#2#19#8'ReadOnly'#9#8'TabOrder'#2#0#7'OnClick'#7#14'TreeV'
+'iew1Click'#7'Options'#11#13'tvoAutoExpand'#17'tvoAutoItemHeight'#16'tvoHide'
+'Selection'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'#14'tvoShowButtons'#12
+'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#6'TPanel'#6'Panel1'#4'L'
+'eft'#2#0#6'Height'#2'B'#3'Top'#2#0#5'Width'#3#171#3#5'Align'#7#5'alTop'#8'A'
+'utoSize'#9#12'ClientHeight'#2'B'#11'ClientWidth'#3#171#3#8'TabOrder'#2#1#0#7
+'TBitBtn'#7'BitBtn1'#21'AnchorSideTop.Control'#7#6'Label1'#18'AnchorSideTop.'
+'Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#6'Panel1'#20'AnchorSideR'
+'ight.Side'#7#9'asrBottom'#4'Left'#3'c'#3#6'Height'#2#30#3'Top'#2#30#5'Width'
+#2'B'#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoSize'#9#20'BorderSpacing.Aro'
+'und'#2#6#7'Caption'#6#4'Load'#10'Glyph.Data'#10'R'#1#0#0'N'#1#0#0'BMN'#1#0#0
+#0#0#0#0'v'#0#0#0'('#0#0#0#18#0#0#0#18#0#0#0#1#0#4#0#0#0#0#0#216#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#0#128#128#0#128#0#0#0
+#128#0#128#0#128#128#0#0#128#128#128#0#192#192#192#0#0#0#255#0#0#255#0#0#0
+#255#255#0#255#0#0#0#255#0#255#0#255#255#0#0#255#255#255#0#238#238#238#238
+#238#238#238#238#238#0#0#0#238#238#238#238#238#238#238#238#238#0#0#0#238#0#0
+#0#0#0#14#238#238#0#0#0#238#0'33330'#238#238#0#0#0#238#11#3'3333'#14#238#0#0
+#0#238#15#176'33330'#238#0#0#0#238#11#251#3'3333'#14#0#0#0#238#15#191#176#0#0
+#0#0#0#0#0#0#238#11#251#251#251#251#14#238#238#0#0#0#238#15#191#191#191#191
+#14#238#238#0#0#0#238#11#251#0#0#0#14#238#238#0#0#0#238#224#0#238#238#238#238
+#0#14#0#0#0#238#238#238#238#238#238#238#224#14#0#0#0#238#238#238#238#238#14
+#238#14#14#0#0#0#238#238#238#238#238#224#0#238#238#0#0#0#238#238#238#238#238
+#238#238#238#238#0#0#0#238#238#238#238#238#238#238#238#238#0#0#0#238#238#238
+#238#238#238#238#238#238#0#0#0#7'OnClick'#7#12'BitBtn1Click'#8'TabOrder'#2#0
+#0#0#6'TLabel'#6'Label1'#22'AnchorSideLeft.Control'#7#6'Panel1'#21'AnchorSid'
+'eTop.Control'#7#6'Panel1'#4'Left'#2#6#6'Height'#2#18#3'Top'#2#6#5'Width'#2
+'B'#20'BorderSpacing.Around'#2#6#7'Caption'#6#9'File name'#11'ParentColor'#8
+#0#0#13'TFileNameEdit'#13'FileNameEdit1'#22'AnchorSideLeft.Control'#7#6'Labe'
+'l1'#21'AnchorSideTop.Control'#7#6'Label1'#18'AnchorSideTop.Side'#7#9'asrBot'
+'tom'#4'Left'#2#12#6'Height'#2#29#3'Top'#2#30#5'Width'#3'<'#3#8'FileName'#6
+'M/home/alexs/work/a/2009-11-24/Magazin_7_RealizaciqTovarovUslug_2009-11-11.'
+'xml'#13'DialogOptions'#11#0#11'FilterIndex'#2#0#15'HideDirectories'#8#11'Bu'
+'ttonWidth'#2#23#9'NumGlyphs'#2#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'
+#0#18'BorderSpacing.Left'#2#6#17'BorderSpacing.Top'#2#6#20'BorderSpacing.Bot'
+'tom'#2#6#9'MaxLength'#2#0#8'TabOrder'#2#1#0#0#0#9'TSplitter'#9'Splitter1'#4
+'Left'#3#201#1#6'Height'#3'p'#2#3'Top'#2'B'#5'Width'#2#5#0#0#6'TPanel'#6'Pan'
+'el2'#4'Left'#3#206#1#6'Height'#3'p'#2#3'Top'#2'B'#5'Width'#3#221#1#5'Align'
+#7#8'alClient'#7'Caption'#6#6'Panel2'#12'ClientHeight'#3'p'#2#11'ClientWidth'
+#3#221#1#8'TabOrder'#2#3#0#9'TListView'#9'ListView1'#21'AnchorSideTop.Contro'
+'l'#7#5'Edit2'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#1#6'Height'#3
+#243#1#3'Top'#2'|'#5'Width'#3#219#1#5'Align'#7#8'alBottom'#7'Anchors'#11#5'a'
+'kTop'#6'akLeft'#7'akRight'#8'akBottom'#0#17'BorderSpacing.Top'#2#6#7'Column'
+'s'#14#1#7'Caption'#6#4'Name'#5'Width'#2'd'#0#1#7'Caption'#6#5'Value'#5'Widt'
+'h'#3'^'#1#0#0#8'TabOrder'#2#0#9'ViewStyle'#7#8'vsReport'#0#0#6'TLabel'#6'La'
+'bel2'#22'AnchorSideLeft.Control'#7#6'Panel2'#21'AnchorSideTop.Control'#7#6
+'Panel2'#4'Left'#2#6#6'Height'#2#18#3'Top'#2#6#5'Width'#2'Q'#20'BorderSpacin'
+'g.Around'#2#6#7'Caption'#6#9'Node name'#11'ParentColor'#8#0#0#6'TLabel'#6'L'
+'abel3'#22'AnchorSideLeft.Control'#7#6'Panel2'#21'AnchorSideTop.Control'#7#5
+'Edit1'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#18#3'T'
+'op'#2'A'#5'Width'#2'N'#20'BorderSpacing.Around'#2#6#7'Caption'#6#10'Node va'
+'lue'#11'ParentColor'#8#0#0#5'TEdit'#5'Edit1'#22'AnchorSideLeft.Control'#7#6
+'Label2'#21'AnchorSideTop.Control'#7#6'Label2'#18'AnchorSideTop.Side'#7#9'as'
+'rBottom'#23'AnchorSideRight.Control'#7#6'Panel2'#20'AnchorSideRight.Side'#7
+#9'asrBottom'#4'Left'#2#12#6'Height'#2#29#3'Top'#2#30#5'Width'#3#203#1#7'Anc'
+'hors'#11#5'akTop'#6'akLeft'#7'akRight'#0#20'BorderSpacing.Around'#2#6#8'Tab'
+'Order'#2#1#4'Text'#6#5'Edit1'#0#0#5'TEdit'#5'Edit2'#22'AnchorSideLeft.Contr'
+'ol'#7#6'Label3'#21'AnchorSideTop.Control'#7#6'Label3'#18'AnchorSideTop.Side'
+#7#9'asrBottom'#23'AnchorSideRight.Control'#7#6'Panel2'#20'AnchorSideRight.S'
,'ide'#7#9'asrBottom'#4'Left'#2#12#6'Height'#2#29#3'Top'#2'Y'#5'Width'#3#203#1
+#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#20'BorderSpacing.Around'#2#6#8
+'TabOrder'#2#2#4'Text'#6#5'Edit2'#0#0#0#0
]);

View File

@ -0,0 +1,135 @@
unit TestXMLReaderUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
EditBtn, StdCtrls, Buttons, ComCtrls, ExtCtrls, DOM, XMLRead;
type
{ TXMLRederForm }
TXMLRederForm = class(TForm)
BitBtn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
FileNameEdit1: TFileNameEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ListView1: TListView;
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
TreeView1: TTreeView;
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
private
FDoc: TXMLDocument;
procedure ParseDoc;
public
{ public declarations }
end;
var
XMLRederForm: TXMLRederForm;
implementation
{ TXMLRederForm }
procedure TXMLRederForm.BitBtn1Click(Sender: TObject);
begin
if Assigned(FDoc) then
FreeAndNil(FDoc);
if FileExistsUTF8(FileNameEdit1.FileName) then
ReadXMLFile(FDoc, UTF8ToSys(FileNameEdit1.FileName));
if Assigned(FDoc) then
ParseDoc;
end;
procedure TXMLRederForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
if Assigned(FDoc) then
FDoc.Free;
end;
procedure TXMLRederForm.FormCreate(Sender: TObject);
begin
if ParamCount > 0 then
begin
FileNameEdit1.FileName:=ParamStrUTF8(1);
BitBtn1Click(nil);
end;
TreeView1Click(nil);
end;
procedure TXMLRederForm.TreeView1Click(Sender: TObject);
var
Node:TDOMNode;
Item:TListItem;
i:Integer;
begin
Edit1.Text:='';
Edit2.Text:='';
if not Assigned(TreeView1.Selected) then exit;
Node:=TDOMNode(TreeView1.Selected.Data);
if not Assigned(Node) then exit;
Edit1.Text:=Node.NodeName;
Edit2.Text:=Node.NodeValue;
ListView1.BeginUpdate;
ListView1.Items.Clear;
if Assigned(Node.Attributes) then
for i:=0 to Node.Attributes.Length-1 do
begin
Item:=ListView1.Items.Add;
Item.Caption:=Node.Attributes[i].NodeName;
Item.SubItems.Add(Node.Attributes[i].NodeValue);
end;
ListView1.EndUpdate;
end;
procedure TXMLRederForm.ParseDoc;
procedure DoFill(AOwner:TTreeNode; Node:TDOMNode);
var
i: integer;
AItem:TTreeNode;
begin
if not Assigned(Node) then exit;
for i:=0 to Node.ChildNodes.Count - 1 do
begin
AItem:=TreeView1.Items.AddChild(AOwner, Node.ChildNodes[i].NodeName);
AItem.Data:=Node.ChildNodes[i];
if not Assigned(TreeView1.Selected) then
TreeView1.Selected:=AItem;
DoFill(AItem, Node.ChildNodes[i]);
end;
end;
begin
TreeView1.Selected:=nil;
TreeView1.Items.BeginUpdate;
TreeView1.Items.Clear;
DoFill(nil, FDoc);
TreeView1.Items.EndUpdate;
TreeView1Click(nil);
end;
initialization
{$I testxmlreaderunit.lrs}
end.