Introduction :
In Automation anywhere V11 we have XML command that will use to read XML data, we have other sub-command using that we can Get Node, Insert Node, Delete Node, Update Node and Validate XML document.
Before get started make sure that you have a sample XML file, if you don't have download it from below link.
Read XML document :
Step 1 : Drag and Drop the Command "Start XML Session" and Select the XML file path.
Step 3: Drag and drop the "Get Node" Command, select the Multiple Nodes Type,
select the XPath expression type and enter the Xpath expression value - //parent_node/child_node
for example for the above xml doc, parent node is catalog and child node is book so i wrote
"//catalog/book" start with double slash.
Step 3: Create the User- defined Variable for what are the Node value you want from the XML document.
for example- From this above sample xml document, i want to Get node for all the book properties, so i created variable as v_Author, v_Title, v_Generation, v_Price, v_Description
Step 4: Use the Loop command for XML process "Each Node in a XML Dataset", make sure session name is same for all the line above including the loop command.
Step 5: Inside the loop command drag and drop the "Get Node" XML command and this time Select the Single Node with same session name and pass the Xpath expression value.
Note : for each book properties use the individual line and pass the particular xpath experssion as below and get the value to respective variable.
//catalog/book[$Counter$]/author Assign value to v_Author,
//catalog/book[$Counter$]/title Assign value to v_Title
//catalog/book[$Counter$]/genre Assign value to v_Generation
//catalog/book[$Counter$]/price Assign value to v_Price
//catalog/book[$Counter$]/description Assign value to v_Description
Step 7: Use the Command "End XML Session"
Step 8: Save the task & Run.
Please refer the below screen shot code for your reference.
Note : Use the other sub-command Insert/ Delete/Update Node by the same method.
Hope this is helpful to you, please share your comments.
Happy Learning!!😊
In Automation anywhere V11 we have XML command that will use to read XML data, we have other sub-command using that we can Get Node, Insert Node, Delete Node, Update Node and Validate XML document.
Before get started make sure that you have a sample XML file, if you don't have download it from below link.
"Sample XML file download"
Read XML document :
Step 1 : Drag and Drop the Command "Start XML Session" and Select the XML file path.
Step 3: Drag and drop the "Get Node" Command, select the Multiple Nodes Type,
select the XPath expression type and enter the Xpath expression value - //parent_node/child_node
for example for the above xml doc, parent node is catalog and child node is book so i wrote
"//catalog/book" start with double slash.
Step 3: Create the User- defined Variable for what are the Node value you want from the XML document.
for example- From this above sample xml document, i want to Get node for all the book properties, so i created variable as v_Author, v_Title, v_Generation, v_Price, v_Description
Step 4: Use the Loop command for XML process "Each Node in a XML Dataset", make sure session name is same for all the line above including the loop command.
Step 5: Inside the loop command drag and drop the "Get Node" XML command and this time Select the Single Node with same session name and pass the Xpath expression value.
Note : for each book properties use the individual line and pass the particular xpath experssion as below and get the value to respective variable.
//catalog/book[$Counter$]/author Assign value to v_Author,
//catalog/book[$Counter$]/title Assign value to v_Title
//catalog/book[$Counter$]/genre Assign value to v_Generation
//catalog/book[$Counter$]/price Assign value to v_Price
//catalog/book[$Counter$]/description Assign value to v_Description
Note : I used Counter variable because Bot will get the node for the first set of book node properties and then in the loop Counter value will get increase +1
Default Counter value is 1Step 6: Show the output variable in the Message Box.
Step 7: Use the Command "End XML Session"
Step 8: Save the task & Run.
Download Code
Please refer the below screen shot code for your reference.
Note : Use the other sub-command Insert/ Delete/Update Node by the same method.
Hope this is helpful to you, please share your comments.
Happy Learning!!😊
0 Comments