Set Attributes Value

This activity is used to set more than one attribute value to an xml file.

Technical Reference

i

 

 

INPUT

AttributeName: Specify the name of the attributes for which the details must be set.

InputString: Specify the input values to be set for the attributes.

NodeName: Specify the node name in which the attribute value must be set.

 

 

 

 

 

MISC

DisplayName: Displays the name of the activity. You can also customize the activity name to help troubleshoot issues faster. This name will be used for logging purposes

SkipOnError: It specifies whether to continue executing the workflow even if it throws an error. This supports only Boolean value “True or False”. By default, it is set to “False.”

True: Continues the workflow to the next step

False: Stops the workflow and throws an error.

Version: It specifies the version of the XML automation feature in use

 

OUTPUT

Output: Declare a variable here to see the output of the updated file.

Result: Returns the success state of the activity.

*Mandatory fields to execute the workflow

Use Case

The following example illustrates how we can use this activity to set more than one
attribute value to a specific node. Here we are going to set the values
{“Chocolate”,”Sauce”} to the attributes {“Test1”,”Test2”} in the node “name”.

Steps to execute the bot

1.      Drag and drop a get XML object which is the scope for all other activities.

2.      Mention the xml path of the file.

3.      Drag and drop the Get Node list activity within the scope.

4.      Specify the node name as “breakfast_menu/food/name”. Here we are mentioning
 the parent node/node/attribute.

5.      Declare a variable here in which the text extracted from the above node is stored as
 an XmlNodeList. Here it is “GNL”.

6.      Now drag and drop a Foreach activity into the scope. This activity is used because we
 have a list of nodes, and we have to set the attributes value to each node.

7.      Change the argument type in ForEach activity as Xmlnode.

8.      Enter the values for ForEach as “Item” in as “GNL.Cast(of xml.XmlNode)”. We use
 this extension here, as we have to convert each Xmlnodelist value to Xmlnode and set
 the attributes value.

9.      Now drag and drop a set attributes value activity into the scope.

10.   Enter the Attribute name as {“Test1”,”Test2”}

11.   Enter the input string as {“Chocolate”,”Sauce”}. These are the new values to be to be
 set to the above-mentioned attributes.

12.   Enter the node name as ”item” as this is the value in which the nodelist values are
 converted to nodes and stored.

13.   Drag and drop a Save Xml activity to the workflow and enter the filepath in which these
 changes are made.

14.   Execute the workflow and open the XML file to see the newly set values of the attributes.

The bot executes the activity and sets the value for the attributes “Test1” as "Chocolate” and 
"Test2” as “Sauce“ in the node “name”.