child1.appendchild(doc.createtextnode(temp));
end;
table.next;
end;
doc.save(xml+'.xml');
memo1.lines.append(doc.xml);
result:=1;
except
on e:exception do
result:=-1;
end;
end;
在button1的onclick事件中调用上面的函数
procedure tform1.button1click(sender: tobject);
begin
if makexml(table1)=1 then
showmessage('xml generated')
else
showmessage('error while generating xml file');
end;
如果你用ie 5.0(或以上版本)打开生成的country.xml文件,它看起来会成下面的样子
- <country>
- <records>
<name>argentina</name>
<capital>buenos aires</capital>
<continent>south america</continent>
<area>2777815</area>
<population>32300003</population>
</records>
- <records>
<name>bolivia</name>
<capital>la paz</capital>
<continent>south america</continent>
<area>1098575</area>
<population>7300000</population>
</records>
.
.
.
- <records>
<name>venezuela</name>
<capital>caracas</capital>
<continent>south america</continent>