Jump to content

Find in xml file specific line and work with it


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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