XML node Trilogy in PAD – Part-II

xml node pad 2

Posted By : Rakesh Pandey

Added :

2 Comments


Hello everyone, today we will see the second part of the XML node Trilogy in PAD. You can go through this link to see the previous article. In this article, we will look below the actions of the XML node in the pad (Power Automate Desktop) for the XML element attribute.
1. Get XML element attributes
2. Set XML element attributes
3. Remove XML element attributes

Before we jump into the above three actions of PAD, I would like to share the XML file. In order to know more about XML attributes, refer to this link.

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book>
    <title lang="en">Harry Potter</title>
    <price currency="INR">29.99</price>
  </book>
  <book>
    <title lang="en">Learning XML</title>
    <price currency="HKD">39.95</price>
  </book>
  <book>
    <title lang="en">Flexmind PowerApps</title>
    <price currency="USD">49.95</price>
  </book>
</bookstore>

In the above example I am using currency attribute of price element. Let’s start !!

Get XML element attribute

This action get the value of an attribute of an XML element. For example, let us consider this below piece of code. Here currency is an attribute for price element which value is INR.

<price currency="INR">29.99</price>
XML element attribute
Flow
XML element attribute
Get Attribute

Parameters explanation

XML Document : Variable coming from read XML file action.
XPath query: /bookstore/book[%input1%]/price. Here [%input1%] is basically a variable which value is equal to user input (an integer).
Attribute Name: Currency
Get Value as: Text Value

Now run the flow to see the result. It will look like below picture.

XML element attribute
Display Result

Set XML element attributes

We use this action to set the value of an attribute. If you see the below picture, set XML’s parameters pretty similar to Get action. Suppose, if we want to set the currency from INR to SGD, then we will use the Set action.

XML element attribute
Set Attribute

Remove XML element attribute

If you want to remove the attribute of an XML element, then in that case you will use this action. Parameters for this action is also very similar to Set and Get actions.
Hope you all will enjoy this article. In our next blog, we will go through the remaining actions of XML node in PAD. So stay tuned.

0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
manos
manos
2 years ago

Hi there!
Thank you for the article, it has been very helpful 🙂

I’ve got a question though. How would we be able to get multiple element attributes from the same xml file? i.e. if my xml looks like this:

how would I get each “FileUrl Attribute?”