How To Extract The Data From A XML file – In UiPath

Some business processes may consume the XML as an input/output to exchange data to/from a web server.

When receiving data from a web server, the data is always a string.

Let’s explore how to extract the field from an XML string!!!

Example

Implementation using UiPath :

Let us implement a workflow which reads a .XML file and extracts the required fields.

Step 1:
Drag “Read Text File” activity into the designer panel, pass the .XML file’s path to it and save the output to a string variable.

Please download the sample .xml file from the link mentioned at the bottom of the article.

Extract Data From A XML File1Extract Data Fro1m A XML 2

Step 2:
Drag “Deserialize XML” activity into the designer panel to deserialize XML string. Supply the variable “xml_Data” to it as input and create a variable called “out_XML” of XDocument type.

Note: If you don’t find the “Deserialize XML” activity in the activities panel, then you have to install UiPath.Web.Activities package

Extract Data From A XML File 2Extract Data From A XML File 3

Step 3:
Drag “For Each” activity into the designer panel and supply the below-mentioned parameters into it.

Values: out_XML.Element(“breakfast_menu”).Elements(“food”)

TypeParameter: System.XML.Linq.XElement

Extract Data From A XML File 4Extract Data From A XML File 5

Step 4:
Use “Message Box” activities to display the contents.

Extract Data From A XML File 6.PNG

Step 5:
Finally, run the project 🙂

Name:
Extract Data From A XML File 7

Price:
Extract Data From A XML File 8

Description:
Extract Data From A XML File 9

Click here to download the Source Code…

Hope it has helped you…

Advertisements

3 thoughts on “How To Extract The Data From A XML file – In UiPath

  1. haswanth

    i write a code of extract multiple images text in folder and the happend is only last image text stored in notepad file but i want all images text using uipath tool please could sugguest any solution

    1. Sure Haswanth, are you storing all the values into same .txt file different .txt files?

    2. Definitely Haswanth, are you using the same notepad to store all the values?

Leave a Reply

%d bloggers like this: