Delphi 的,希望对你 有用。
var
pt: PdnTerm;
pgt: PdnGameType;
pg: PdnGame;
pp: PdnPlay;
xml: IXmlDomDocument;
e1, e2, e3, e4, e5: IXmlDomElement;
begin
xml := ComsDOMDocument26.Create;
xml.loadXML('');
e1 := xml.selectSingleNode('/Source') as IXmlDomElement;
pt := s^.Term;
while pt <> nil do
begin
e2 := xml.createElement('Term');
e2.setAttribute('Name', pt^.Name);
e1.appendChild(e2);
pgt := pt^.GameType;
while pgt <> nil do
begin
e3 := xml.createElement('GameGroup');
e3.setAttribute('Name', pgt^.Name);
e2.appendChild(e3);
pg := pgt^.Game;
while pg <> nil do
begin
e4 := xml.createElement('Game');
e4.setAttribute('Time', pg^.Time);
e4.setAttribute('Staff', pg^.Staff);
e4.setAttribute('E_URL', pg^.Eur_play_url);
e4.setAttribute('A_URL', pg^.Asia_play_url);
e4.setAttribute('W_R', pg^.A_O);
e4.setAttribute('P_R', pg^.A_P);
e4.setAttribute('L_R', pg^.A_G);
e3.appendChild(e4);
pp := pg^.Play;
while pp <> nil do
begin
e5 := xml.createElement('Play');
e5.setAttribute('CompanyName', pp^.Company);
e5.setAttribute('W', pp^.Win);
e5.setAttribute('P', pp^.Peace);
e5.setAttribute('L', pp^.Lose);
e4.appendChild(e5);
pp := pp^.Next;
end;
pg := pg^.Next;
end;
pgt := pgt^.Next;
end;
pt := pt^.Next;
end;
xml.save(s^.Name + '.xml');
end;
生成的 文档 如下(示意):