Jump to content
Sign in to follow this  
maniootek

Find in xml file specific line and work with it

Recommended Posts

maniootek

Hi guys.

I have database with a codes and numbers

Local $codes = [9, 79, 11]
Local $numbers = [45, 45, 35]

each code mean some number

code 9 = 3

code 79 = 4

code 11 = 2

 

Now, I am looking for some way to find this line in my xml file:

<Atrybut Nazwa="Autoit" Typ="">009:1, 079:2, 011:35</Atrybut>

(009 is my code, :1 is quantity)

and work with it to get:

<Atrybut Nazwa="Waga" Typ="">81</Atrybut>

Why 81?

81 = code 9*1 + code 79*2 + code 11*35

91 = 3*1 + 4*2 + 2*35

I think there must be some function to load file, find line which contains "Autoit", work with this line to extract codes and quantities, calculate total number, write new line with new results and save file.

Any idea?

Edited by maniootek

Share this post


Link to post
Share on other sites
Jury

As for:

"Now, I am looking for some way to find this line in my xml file:"

here is a start - no doubt others will have a better understanding as to the maths or cleverer ways to do this.

$sInput = '<Atrybut Nazwa="Autoit" Typ="">009:1, 079:2, 011:35</Atrybut>'

; Option 3, global return, old AutoIt style
Local $aArray = StringRegExp($sInput, '(\d+):(\d+),\s*(\d+):(\d+),\s*(\d+):(\d+)', 3)
For $i = 0 To UBound($aArray) - 1
  ConsoleWrite($aArray[$i] & @CRLF)
Next

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×