h3ir Posted July 21, 2008 Posted July 21, 2008 Have a look at this: It will read a simple XML Structure and Output it as Array and write additional the parsed XML in a Log-File... expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.12.0 Author: h3ir Script Function: Easy XML Parser XML Example: <Path> <Point> <Description>#1</Description> <X>120</X> <Y>300</Y> </Point> <Point> <Description>#2</Description> <X>150</X> <Y>250</Y> </Point> </Path> #ce ---------------------------------------------------------------------------- #include-once Func __ParseXML($XMLfile) FileDelete(@ScriptDir & "\parse.log") $file = FileOpen($XMLfile, 0) $i = 0 $j = 0 While 1 $i = $i+1 $line = FileReadLine($file, $i) $line = StringReplace($line, " ", "") $line = StringReplace($line, @tab, "") If $line == "<Point>" Then $j = $j+1 EndIf If $line == "</Path>" Then ExitLoop EndIf WEnd Dim $Path[$j][3] $Point = 0 $i = 0 $j = -1 While 1 $i = $i+1 $line = FileReadLine($file, $i) $line = StringReplace($line, " ", "") $line = StringReplace($line, @tab, "") If $line == "<Point>" Then $Point = 1 $j = $j+1 EndIf If $Point == 1 AND StringLeft($line,13)='<Description>' then $trim = StringTrimLeft($line,StringInstr($line,'<Description>')+12) $Path[$j][0] = StringTrimRight($trim,14) EndIf If $Point == 1 AND StringLeft($line,3)='<X>' then $trim = StringTrimLeft($line,StringInstr($line,'<X>')+2) $Path[$j][1] = StringTrimRight($trim,4) EndIf If $Point == 1 AND StringLeft($line,3)='<Y>' then $trim = StringTrimLeft($line,StringInstr($line,'<Y>')+2) $Path[$j][2] = StringTrimRight($trim,4) EndIf If $Point == 1 AND $line == "</Point>" Then $Point = 0 EndIf If $Point == 0 AND $line == "</Path>" Then ExitLoop EndIf WEnd $maxArray = Ubound($Path) $i = 0 While $i <= $maxArray-1 $log = FileOpen(@ScriptDir & "\parse.log",1) FileWriteLine($log, $Path[$i][0]&@tab&$Path[$i][1]&@tab&$Path[$i][2]) FileClose($log) $i = $i+1 WEnd Return $Path EndFunc
darzanmihai Posted July 22, 2008 Posted July 22, 2008 Could you create a XML file with Autoit Script?? I do not like stupid and idiot people that write idiot things...If you are one, do not write.
Andreik Posted July 22, 2008 Posted July 22, 2008 Could you create a XML file with Autoit Script??Yes.
h3ir Posted July 22, 2008 Author Posted July 22, 2008 Could you create a XML file with Autoit Script??I will create a example script for this later...
darzanmihai Posted July 23, 2008 Posted July 23, 2008 I will create a example script for this later...I am verry interested about creating an XML file. I do not like stupid and idiot people that write idiot things...If you are one, do not write.
darzanmihai Posted July 23, 2008 Posted July 23, 2008 Yes.I knew that it could be done, but I wos wondering if h3ir could make a script example. muttley I do not like stupid and idiot people that write idiot things...If you are one, do not write.
weaponx Posted July 23, 2008 Posted July 23, 2008 I knew that it could be done, but I wos wondering if h3ir could make a script example. muttleyYou should be using a standards based XML UDF:http://www.autoitscript.com/forum/index.php?showtopic=19848There are plenty of good examples:#541825
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now