本文整理自网络,侵删。
uses XMLIntf, XMLDoc, INIFiles;
procedure INI2XML(const pINIFileName: string; const pXML: IXMLNode;
const AsAttributes: Boolean = true);
var
lINIFile: TIniFile;
lSections, lItems: TStringList;
iSections, iItems: integer;
lNode: IXMLNode;
begin
lINIFile := TIniFile.Create(pINIFileName);
try
lSections := TStringList.Create;
try
lItems := TStringList.Create;
try
lINIFile.ReadSections(lSections);
for iSections := 0 to pred(lSections.Count) do
begin
lItems.Clear;
lINIFile.ReadSection(lSections[iSections], lItems);
lNode := pXML.AddChild(StringReplace(lSections[iSections], ' ', '',
[rfReplaceAll]));
for iItems := 0 to pred(lItems.Count) do
begin
if AsAttributes then
lNode.Attributes[lItems[iItems]] :=
lINIFile.ReadString(lSections[iSections], lItems[iItems], '')
else
lNode.AddChild(lItems[iItems]).Text :=
lINIFile.ReadString(lSections[iSections], lItems[iItems], '');
end;
lNode := nil;
end;
finally lItems.Free;
end;
finally lSections.Free;
end;
finally lINIFile.Free;
end;
end;
相关阅读 >>
Delphi xe10 针对全面屏手机端无法全面显示,下方显示黑条的处理
Delphi win7,win2008,win2003,winxp 屏蔽ctrl+alt+del
Delphi中inputbox 和inputquery 函数的使用
Delphi 手机app打开一个安卓系统支持的文件,比如 pdf
Delphi xe8在firemonkey tlistbox中显示图像
更多相关阅读请进入《Delphi》频道 >>