Статьи по программированию
примеры программного кода
Delphi, Kylix, C, C++, SQL, Visual Basic, Bash, Assembler, 1С
Qt, KOL, MFC, Rx Library, Windows, Linux, Mac OS
Конвертировать INI файл в XML
Опубликовано codeLocker в 24.07.2008 в 15:23.
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;
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;
Материал похожий на Конвертировать INI файл в XML
- WMF в BMP
- Преобразование цвета RGB <-> HLS
- Конвертация римских цифр в арабские
- Конвертировать результат запроса в XML и обратно
Метки
delphi конвертировать
Навигация
Сейчас на сайте
Сейчас на сайте 0 пользователей и 2 гостя.
Статистика
Всего материалов: 1387