不会这么严重吧
procedure TfrmXML.Button1Click(Sender: TObject);
begin
XMLDocument1.Active:=true;
Memo1.Lines.Clear;
n1:=XMLDocument1.DocumentElement;
if n1=Nil then
exit;
Memo1.Lines.Add(n1.NodeName);
n2:=n1.ChildNodes.Last;
if N2=Nil then
exit;
Memo1.Lines.Add(n2.NodeName);
n3:=n2.ChildNodes.First;
while N3<>Nildo
begin
Memo1.Lines.Add(N3.Attributes['OrderNo']
+N3.Attributes['ItemNo']+' '
+N3.Attributes['PartNo']+' '
+N3.Attributes['Qty']+' '
+N3.Attributes['Discount']);
N3:=n3.NextSibling;
end;
XMLDocument1.Active:=false;
end;
procedure TfrmXML.Button2Click(Sender: TObject);
var
i: Integer;
begin
XMLDocument2.Active:=True;
XMLDOcument2.Encoding:='GB2312';
n1:=XMLDocument2.AddChild('单订项数据');
for i:=3 to Memo1.Lines.Countdo
N1.AddChild('X'+IntToStr(i));
XMLDocument2.SaveToFile('d:/output.xml');
XMLDocument2.Active:=false;
end;