1
0
mirror of https://github.com/Kirill/simplexml.git synced 2025-07-16 10:44:17 +02:00

Version 1.0.1

This commit is contained in:
Kirill Krasnov
2010-11-06 22:16:58 +02:00
parent 51b4067d1b
commit bef25364bc
7 changed files with 4622 additions and 0 deletions

13
Sample/Test.dpr Normal file
View File

@ -0,0 +1,13 @@
program Test;
uses
Forms,
TestForms in 'TestForms.pas' {TestForm};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TTestForm, TestForm);
Application.Run;
end.

BIN
Sample/Test.res Normal file

Binary file not shown.

6
Sample/Test.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="windows-1251"?>
<root>
<elem1 a1="v1" a2="v2"> 1</elem1>
<!-- -->
<elem2 a1="v1" a2="v2"> 2</elem2>
</root>

43
Sample/TestForms.dfm Normal file
View File

@ -0,0 +1,43 @@
object TestForm: TTestForm
Left = 267
Top = 132
Width = 696
Height = 480
Caption = 'TestForm'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 40
Top = 16
Width = 75
Height = 25
Caption = 'Open'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 40
Top = 60
Width = 361
Height = 309
Lines.Strings = (
'Memo1')
TabOrder = 1
end
object Button2: TButton
Left = 128
Top = 16
Width = 75
Height = 25
Caption = 'Save'
TabOrder = 2
OnClick = Button2Click
end
end

81
Sample/TestForms.pas Normal file
View File

@ -0,0 +1,81 @@
unit TestForms;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SimpleXML, StdCtrls;
type
TTestForm = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TestForm: TTestForm;
implementation
{$R *.dfm}
procedure TTestForm.Button1Click(Sender: TObject);
var
aDoc: IXmlDocument;
anElem2: IXmlNode;
begin
// ������� ������ �������� XML
aDoc := CreateXmlDocument;
// ��������� �� �����
aDoc.Load(ExtractFilePath(ParamStr(0)) + '\Test.xml');
// ������� � Memo1 ������ ����� ��������� XML
Memo1.Lines.Text := aDoc.Xml;
Memo1.Lines.Add('------------------------');
// ���� ������ ������� � ����� 'elem2'
anElem2 := aDoc.DocumentElement.SelectSingleNode('elem2');
// ������� � Memo1 XML-����� �������� anElem2
Memo1.Lines.Add(anElem2.Xml);
Memo1.Lines.Add('------------------------');
// ������� � Memo1 �������� �������� 'a2' �������� anElem2
Memo1.Lines.Add(anElem2.GetAttr('a2'));
end;
procedure TTestForm.Button2Click(Sender: TObject);
var
aDoc: IXmlDocument;
anElem: IXmlElement;
begin
// ������� ������ �������� XML � �������� ��������� "root-element"
aDoc := CreateXmlDocument('xml');
// ������� ������� 'elem' � ��������� ��� � �������� ��������� �������� ��� ���������
anElem := aDoc.DocumentElement.AppendElement('elem');
// ��������� �������� 'a1' � 'a2' � ������ ��������
anElem.SetAttr('a1', 'elem1 a1');
anElem.SetAttr('a2', 'elem1 a2');
// ��������� ��� ���� ������� 'elem'
anElem := aDoc.DocumentElement.AppendElement('elem');
anElem.SetAttr('a1', 'elem2 a1');
anElem.SetAttr('a2', 'elem2 a2');
// ��������� �������� � ����
aDoc.Save(ExtractFilePath(ParamStr(0)) + '\Test2.xml');
end;
end.

BIN
SimpleXML.chm Normal file

Binary file not shown.

4479
SimpleXML.pas Normal file

File diff suppressed because it is too large Load Diff