NativeXml Help
Example B: Access to nodes
This example shows how to access individual nodes in the XML file. A node can be anything from a normal XML tag, comment, CDATA structure, etcetera. The example shows how to list the first 2 levels of nodes by a simple double loop.

Add a TEdit, TButton and TMemo to your form, then connect the code below to the OnClick event of the button. Fill in the filename in Edit1 and then click the button, the first two levels of nodes will be listed in the memo control.

procedure TForm1.Button2Click(Sender: TObject);
var
  i, j: integer;
  ADoc: TNativeXml;
begin
  Memo1.Lines.Clear;
  ADoc := TNativeXml.Create;
  try
    ADoc.LoadFromFile(Edit1.Text);
    if assigned(ADoc.Root) then with ADoc.Root do
      for i := 0 to NodeCount - 1 do begin
        Memo1.Lines.Add(Nodes[i].Name);
        for j := 0 to Nodes[i].NodeCount - 1 do
          Memo1.Lines.Add(' ' + Nodes[i].Nodes[j].Name);
      end;
  finally
    ADoc.Free;
  end;
end;