Jump to content

Recommended Posts

Posted

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 ???

Posted

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 ???

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.

Posted

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 ?

Posted (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 by Gif

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...