NaPeK Posted August 6, 2007 Posted August 6, 2007 Hi i need to count "<" and "/>" in xml file and check if they number is even number then show message box how to do it ???
SadBunny Posted August 6, 2007 Posted August 6, 2007 Hi i need to count "<" and "/>" in xml file and check if they number is even number then show message boxhow to do it ???Check the help for examples of StringInStr() and/or StringRegExp() (the latter is harder to formulate, but if done, way cleaner and shorter). Both can give you the number of occurences of some string (only StringInStr() will require some looping). Roses are FF0000, violets are 0000FF... All my base are belong to you.
NaPeK Posted August 6, 2007 Author Posted August 6, 2007 tryed already with no results... thats why asking for help
jvanegmond Posted August 6, 2007 Posted August 6, 2007 StringSplit also returns the amount of > and < github.com/jvanegmond
NaPeK Posted August 7, 2007 Author Posted August 7, 2007 MyNameIs i tryed to fit your code hereFunc Load() $Load = FileOpenDialog("Choose file" , @ScriptDir , "XML file (*.xml)") If @error Then MsgBox(4096,"","No file(s) choosed") Exit Else ; here code EndIf EndFuncbut all the time it returns me values 1 and how to check if returned value is even number ?
Gif Posted August 7, 2007 Posted August 7, 2007 (edited) MyNameIs i tryed to fit your code here Func Load() $Load = FileOpenDialog("Choose file" , @ScriptDir , "XML file (*.xml)") If @error Then MsgBox(4096,"","No file(s) choosed") Exit Else ; here code EndIf EndFunc but all the time it returns me values 1 and how to check if returned value is even number ? do this: Func Load() $Load = FileOpenDialog("Choose file" , @ScriptDir , "XML file (*.xml)", 1) If Not @error Then $op = FileOpen($Load, 0) $string = FileRead($op) StringRegExpReplace($string, "\<", "") $replaced1 = @extended StringRegExpReplace($string, "\\>", "") $replaced2 = @extended MsgBox(0, 0, "There are " & $replaced1 & " < and" & $replaced2 & " /> in $string") FileClose($op) EndIf EndFunc Edited August 7, 2007 by Gif
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