그림과 같은 결과를 얻기위한 소스입니다.
procedure TForm1.FormCreate(Sender: TObject);
var LNodeElement, NodeChild, NodeGChild: IXMLNode;
begin
XMLDoc.Active:= True;
XMLDoc.Version:='1.0';
XMLDoc.StandAlone:='yes';
XMLDoc.DocumentElement:= XMLDoc.CreateNode('DATAPACKET', ntElement, '');
XMLDoc.DocumentElement.Attributes['Version']:= '2.0';
LNodeElement:= XMLDoc.DocumentElement.AddChild('METADATA');
NodeChild:= LNodeElement.AddChild('FIELDS');
NodeGChild:= NodeChild.AddChild('FIELD', -1);
NodeGChild.Attributes['attrname']:= 'Name';
NodeGChild.Attributes['fieldtype']:= 'string';
NodeGChild.Attributes['WIDTH']:= '24';
NodeChild:= LNodeElement.AddChild('PARAMS',-1);
NodeChild.Attributes['DEFAULT_ORDER']:= '1';
NodeChild.Attributes['PRIMARY_KEY']:= '1';
NodeChild.Attributes['LCID']:= '2057';
LNodeElement:= XMLDoc.DocumentElement.AddChild('ROWDATA');
NodeChild:= LNodeElement.AddChild('ROW', -1);
NodeChild.Attributes['Name']:= 'Argentina';
NodeChild.Attributes['Capital']:= 'Buenos Aires';
NodeChild.Attributes['Continent']:= 'South America';
NodeChild.Attributes['Area']:= '2777815';
NodeChild.Attributes['Population']:= '32300003';
NodeChild:= LNodeElement.AddChild('ROW', -1);
NodeChild.Attributes['Name']:= 'Bolivia';
NodeChild.Attributes['Capital']:= 'La Paz';
NodeChild.Attributes['Continent']:= 'South America';
NodeChild.Attributes['Area']:= '1098575';
NodeChild.Attributes['Population']:= '7300000';
XMLDoc.SaveToFile('./dest.xml');
Application.ProcessMessages;
memo1.Lines.LoadFromFile('./dest.xml');
end;