How to get Elements having specific Attribute from XML using LINQ in UiPath (Where clause in xml data)

Problem statement — We need to extract book details from the XML data where the genre is ‘fantasy’

Book.XML

Import system.xml and system.xml.linq to the project.

Now, add 2 assign activities to the workflow area and write the following code.

This will load the xml and save it into element of ‘XElement’ type

The above query will get the data based where ‘Genre’ Value in ‘Fantasy’ and will store in an IEnumerable

Let’s run the video

YouTube: How to get elements having specific attribute from XML using LINQ(Where clause in xml) - YouTube

Code: UiPathSamples/15 - Get Elements having specific Attribute from XMLL using LINQ at main · manojbatra071/UiPathSamples · GitHub

Medium: UiPathSamples/15 - Get Elements having specific Attribute from XMLL using LINQ at main · manojbatra071/UiPathSamples · GitHub

Happy Automation