function StrToPoint(Str:
string): TPoint;
var
s, s1:
string;
p: integer;
begin
s := StringReplace(Str, '
(', '
', []);
s := StringReplace(s, '
)', '
', []);
p := Pos('
:', s);
s1 := Copy(s, 1, p-1);
result.X := StrToInt(s1);
Delete(s, 1, p);
result.Y := StrToInt(s);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
s:
string;
start, ende: TPoint;
Element: TJclSimpleXMLElems;
begin
Refresh;
XML.LoadFromString(Editor.Lines.Text);
for i := 0
to XML.Root.Items.Count - 1
do begin
Element :=
XML.Root.Items[i].Items;
if Assigned(Element.ItemNamed['
typ'])
then begin
if Element.ItemNamed['
typ'].Value = '
linie'
then begin
if Assigned(Element.ItemNamed['
farbe'])
then begin
s := Element.ItemNamed['
farbe'].Value;
if s = '
rot'
then begin
Canvas.Pen.Color := clred;
end;
// usw.
// viell. html farbcodes parsen
end;
if
Assigned(Element.ItemNamed['
start'])
and
Assigned(Element.ItemNamed['
ende'])
then begin
start := StrToPoint(Element.ItemNamed['
start'].Value);
ende := StrToPoint(Element.ItemNamed['
ende'].Value);
Canvas.MoveTo(start.X, start.Y);
Canvas.LineTo(ende.X, ende.Y);
end;
end;
if Element.ItemNamed['
typ'].Value = '
rechteck'
then begin
//...
end;
end;
// else Fehler behandeln
end;
end;