(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, DOM, XMLRead;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1; 

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);

var
  doc : TXMLDocument;
  nodelist : TDOMNodelist;
  i : integer;
  comp : TComponent;

begin
  ReadXMLFile(doc, 'C:\work\da.xml');
  nodelist := doc.GetElementsByTagName('komp');
  for i := 0 to nodelist.Count-1 do begin
    comp := FindComponent(nodelist[i].TextContent);
    if comp is TLabel then begin
      TLabel(comp).Caption := nodelist[i].ParentNode.FindNode('value').TextContent;
    end;
  end;
  doc.Free;
end;

end.
