This activity is used to add more than one attribute to the same node name present in
a list of nodes of an xml file.
Technical Reference
INPUT |
AttributeName: Specify the attribute names to be added to a node as a list of string. |
|
InputString: Specify the input value to be added to the respective attribute as a list of string. |
||
NodeName: Specify the nodename which has all the stored values from the specified list of nodes of the given xml file. |
||
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 result of the updated node in the XML file. |
|
Result: Declare a variable here to see the success state of the activity. |
*Mandatory fields to execute the workflow
Use Case
The following activity illustrates how we can use this activity to add two attributes“Test1= Geo and Test2= Leo” to the nodes “name” of the XML file which has a list of
nodes.This activity requires us to use a Get node list activity, for each activity and a
save xml activity.
Steps to execute a 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 into scope.
4. Double click on the activity and enter the node name as a string to which the attributes
has to be added. Here we are going to add attributes to the child node “name” under
the parent node “food” under the main node “breakfast_menu”. So, the nodename
will be “breakfast_menu/food/name”.
5. Declare a variable in the Xmlnode box of the output segment. The list of nodes taken
from this activity is stored in this variable. Here it is “Attrnode”.
6. Now drag and drop a ForEach activity to the workflow.
7. Change the argument type for the ForEach activity as Xmlnode.
8. Enter the value for Foreach as “item” and the value for in as,
above declared variable.Cast(of xml.xmlnode) which is Attrnode.Cast(of xml.xmlnode).
The values are entered this way as we have to enter the attribute value to each “name”
node in a loop for all the nodes that has the nodename “name” .
9. Now drag and drop a create attributes activity into the ForEach activity.
10. Specify the attribute name and input string as a list of string values.
11. Here the attribute name is Test1 and Test 2. So its entered as
new string(){“Test1”,”Test2”}
12. Next specify the input value for the given attribute as a list of string. Here the input
value is Geo and Leo. So it is entered as new string()(“Geo”,”Leo”}
13. Specify the node name as “item” which has the list of nodes of the xml file.
14. Now drag and drop a save xml activity to save the xml file with the newly added attributes.
15. Execute the workflow and once the execution is over, open the xml file to see the newly
added attributes.
The bot executes the activity and creates attributes Test1="Geo” and Test2 = “Leo” to the
specified nodename “name” throughout the xml file.