Sometimes you may want/need to read a standard INI data file and output it to an XML format. There are several ways to do this, but here is just one. You’ll need KiXtart 4.61 in order to use the Replace() function. Enjoy (and Merry Christmas!)
KiXtart Code
Break ON
; requires KiXtart 4.61 or later!!!
If @kix <= "4.60"
? "this script requires 4.61 or later!"
Exit
EndIf
$strFileName = "s:\scripts\test.ini"
$quote = Chr(34)
$tab = Chr(9)
Dim $linecount, $fHandle, $strLine, $outer, $keyset, $subkeyformat
Dim $name, $value
$subkeyFormat = 1
$fHandle = FreeFileHandle()
$outer = ""
If Open($fHandle, $strFileName) = 0
$strLine = ReadLine($fHandle)
While @error = 0
Select
Case Left($strLine,1) = "["
$outer = Replace(Replace($strLine, "]", ""), "[", "")
? "<$outer>"
Case InStr($strLine, "=") <> 0
$keyset = Split($strLine, "=")
$name = $keyset[0]
$value = $keyset[1]
If $subkeyFormat == 1
? "$tab- "
Else
? "$tab<$name>$value</$NAME>"
EndIf
Case 1
If $outer <> ""
? "</$OUTER>"
$outer = ""
EndIf
EndSelect
$strLine = ReadLine($fHandle)
Loop
$=Close($fHandle)
EndIf
No comments:
Post a Comment