Execute XPath expression Action in Desktop flow using Microsoft Power Automate

Microsoft Power Automate, is a software by Microsoft for automation of recurring tasks. It is part of the Microsoft Power Platform line of products together with products such as Power Apps and Power BI. More Details https://powerautomate.microsoft.com/en-us/

Desktop flows are the existing robotic process automation (RPA) capabilities in Power Automate and enable to automate all repetitive desktop processes. More Details https://docs.microsoft.com/en-us/power-automate/desktop-flows/introduction.

Power Automate provides the capability to use desktop flows to manage XML attributes and elements. Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data.

Execute XPath expression action is used to extract values from an XML document based on the provided XPath query.

Reading this article, you can learn how to Execute XPath expression in Desktop flow using Microsoft Power Automate.

The following important tools are required for developing Microsoft Power Automate,

  1. Windows 10/11 (Recommended)
  2. Power Automate Desktop - Download the Power Automate installer

Now we can discuss step by step App development.

Step 1. Open Microsoft Power Automate -> New Flow, Next, Give the Flow name as PADExecuteXPathexp, Click the Create button,

Microsoft Power Automate

After that, we are able to see the Desktop flow,

Power Automate Actions

Step 2. For Testing Execute XPath expression action ,

First, Add the Read XML from file action, Set the File path Parameter as F:/Sample.xml.

<articles>

<article>
  <title>Read XML from file</title>
  <publish>C# Corner</publish>
  <author>Vijayaragavan S</author>
  <heading>Power Automate Article</heading>
  <body>Read the contents of an XML file into a variable</body>
</article>

<article>
  <title>Execute XPath expression</title>
  <publish>C# Corner</publish>
  <author>Vijayaragavan S</author>
  <heading>Power Automate Article</heading>
  <body>Extract values from an XML document based on the provided XPath query</body>
</article>

</articles>

And Variables produced parameter as XmlDocument and click Save.

Read XML from File

Next, Add the Execute XPath expression action, Set the XmlDocument Parameter as %XmlDocument% , XPathquery parameter as articles/article/title, Get First Value  parameter option as Disabled and Variables produced parameter as XPathResults and click Save,

Execute XPath Expression

For Displaying Result,

Add the Display message action and Set the Message box Title Parameter as DispmsgExcXpath, Message to display Parameter as % XPathResults%  Click Save Button

Display message

Now, Save the PADExecuteXPathexp Desktop Flow,

PADExecuteXPathexp Desktop Flow

Step 3. Now we can run your PADExecuteXPathexp Desktop Flow in Microsoft Power Automate.

The output of the PADExecuteXPathexp is.

PADExecuteXPathexp

Summary

Now you are successfully tested Execute XPath expression Action in Desktop flow - PADExecuteXPathexp in Microsoft Power Automate.


Similar Articles