delphi IniFile To XML


本文整理自网络,侵删。

  

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 memo控件对粘贴板的支持

Delphi 创建大窗口

Delphi中inputbox 和inputquery 函数的使用

Delphi中使用 twebbrowser 编辑网页

Delphi post登陆Delphi盒子论坛源码

Delphi统计字数(汉字+字母+符号)

Delphi 手机app打开一个安卓系统支持的文件,比如 pdf

Delphi xe8在firemonkey tlistbox中显示图像

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...