XML Node in Power Automate Desktop


Posted By : Rakesh Pandey

Added :

No Comments


Happy New Year readers !! Hope you all are doing well. In today’s article, we will see how to use XML Node in Power Automate Desktop. You can refer to this link to glance through the previous articles on PAD. So let’s begin with how to use XML Node in PAD. We will see below the actions of the XML node.
1. Read XML from file
2. Write XML to file
3. Execute XPath expression

Read XML from file

This action read the contents of an XML file into a variable. Before proceeding to this step we will create a sample XML file as shown below. The file name is BooksDetails. Refer to this W3Schools site for more examples.

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book>
    <title lang="en">Harry Potter</title>
    <price>29.99</price>
  </book>
  <book>
    <title lang="en">Learning XML</title>
    <price>39.95</price>
  </book>
  <book>
    <title lang="en">Flexmind AZ-400</title>
    <price>49.95</price>
  </book>
</bookstore>
XML Node in PAD
Read XML file

Select the parameters for the read xml file action. Here I have kept the default encoding. You can select depending on your XML file.

Execute XPath expression

Extract values from an XML document based on the provided Xpath query. We will drag this action below the read xml action.

XML Node in PAD
Execute XPath

Execute XPath Parameters

XML document to parse: Pass the variable which collects the XML file data. Here in this case this value is %XmlDocument%.
XPath query: /bookstore/book[3]/title. Please refer to this link for more details on the XPath query. I am also not very good at writing XPath queries. 🙂 Therefore I have taken a simple one to demonstrate this example. /bookstore/book[3]/title, fetches title of the third book of bookstore node.

Now we will display this action in a display message box to show the result.

XML Node in PAD
Display Message

After completing the above steps, run the flow. It will display message like below.

Display Result

Write XML to file

Write the contents of an XML node variable into a file. We can use this action to write an XML file. Refer to the below image for parameters. You can see the below example, I have updated the code from Flexmind AZ-400 to Flexmind PowerApps.

Write XML File

Now run the flow, it will update the whole XML file.

Hope you all will like this article on how to use XML Node in PAD (Power Automate Desktop). In our upcoming article, we will discuss the other XML actions of PAD. Stay tuned !!

5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments