cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mktranslation
Helper I
Helper I

Looking for a way to extract a piece of text to a variable

I am looping through many xmls with the same structure but different number of rows. I need to extract number from such line.

<v:sampleDataSet dataSetName="990">

I have many identical lines (apart from the number) in each xml but I need to extract only the last one.

I only managed to save entire xml to a variable separated to lines with the action "read text from file".

I can set a variable from any line of this xml by using set variable action and referencing the the line number, but I don't know how to make reference to a variable line number - cause I repeat this operation for many files with different line count.

7 REPLIES 7
Benny_1857
Helper III
Helper III

1. Input the text into variable1 ( I test <v:sample 110 DataSet 125 dataSet125Name="990.01">)

2. Recognize  the entities by number for Variable1

    in this sample it will have 2 same columns 3 rows with number 110, 125, 990.01

3. Launch a new excel and write it into A1

4. Get the first freerow of the excelinstance

5. ConditionLoop FirstFreeRow > 1

6. DeleteRow from excel, 1st row

7. Get FirstFreeRow again

8. Decrease Variable by 1

9. EndLoop

10.Read A1 from Excel

11.Close Excel without save

 

Then you could set a bigger loop to include those steps

Benny_1857_0-1642641148057.png

 

MichaelAnnis
Super User
Super User

Deleted

Benny, thank you for this description. Although, I am afraid I didn't provide enough details. My xml has many different lines, and only some of them look like that. See the screenshot for reference.

mktranslation_0-1642662982830.png

I want to look for the last  <v:sampleDataSet dataSetName=

in this case I need to extract:  935 to a variable.

Benny, thank you for this description. Although, I am afraid I didn't provide enough details. My xml has many different lines, and only some of them look like that. See the screenshot for reference.

mktranslation_1-1642663165744.png

 

I want to look for the last  <v:sampleDataSet dataSetName=

in this case I need to extract:  935 to a variable.

I am afraid I can't loop in such a way - I already have a loop for each file. 

My flow will go through many xmls each time saving each of them into one variable that will be used to other processes.

Sorry - it's hard to explain without looking into the specific flow.

I achieved my aim with a different method, by processing values within Excel and getting them from it. Appreciate your help though.

Benny_1857
Helper III
Helper III

Congratulations!

Yes, read all file path at same time and copy into excel to use formular or PQ to delimiter is a good solution but hard to explain. IOI

Guriga
Advocate II
Advocate II

First, read the XML from the file into a variable.

After you parse text with this variable it will give you all the positions of the specific text in the XML.

Then for each loop to go through the XML to get subtext and save it if you need it. %CurrentItem+30% give you the location of the number so you need to read 3 characters.

Guriga_5-1643297381198.png

 

Guriga_4-1643297370883.png

 

 

Guriga_3-1643297317029.png

Hope the content above may help you.

Best Regards

If my answer helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,240)