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.
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.
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.
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.