How to extract all the ocurrences of a node in a XML File

Hey there! Have a good day! I have a question for you.

I have this xml and what I have to do is extract all the times the “Retencion”/“Importe” element appears.
I tried to do it with a for each in a deserialized string, but failed. Some help?
I’m a new user and i cant upload files, so, there is a screenshot

Hi @RossBastian,

You could try to read the .xml with the Read Text File activity https://docs.uipath.com/activities/docs/read-text-file , and you are getting as result a string variable (let’s say str).

Then, in order to get your number you could get it thru:

Regex.Matches(str,Regex.Escape("Retencion")).Count.ToString --> for counting how many times there is “Retencion”

Regex.Matches(str,Regex.Escape("Importe")).Count.ToString --> for counting how may times there is “Importe”

Hope this helps
Best regards,
Marius

You should try XPath. XPath can be used to navigate through elements and attributes in an XML document.

@RossBastian - Please check this post…

1 Like