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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg75tGgTV9XOlS2udcfridACciSyJ4coG2XHepLqWQ_AaKSpjULH3TcjZ7fh7JxPTrFy4G5C7PdgVISagwKnDsndhqZiL1oq45Gl20jZsgNdNK3uIlL0i_K6Sm7pGXxuzW7aQFLhc93Ass/s320/xml_1.PNG)
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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhbqlVla3yg7Md1f03zAiCQZgkU6Eh7lKr4LshG3VmBjOo3vfFw396cmHz5YRRMuvvhdknIMhhWbexCdSoAj3hrOqJSLSkNWz0SKi4-FY78PxVjGfGwVu78fN4Sj6Gb0930JBNbpMItNQ/s320/xml_2.PNG)
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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQMh6MEbCxeb-RWmhZ6A2jVx4H6OiRDJZlyZ1H6iBEDY-6RN-zlWdHOpLWaj-9BM-RzdDNT5HOLCucjxDrv-K9IFz05orIswaUJRqLx-7WiSDIComBHUQLf02j0ctVTHZhJWkE2sstWuo/s320/xml_6.PNG)
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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPLYJem1lYBAnZ50FTh1xhxkRgGxgyumW5sshmIFC8Hb_T1NAAVoR7f5w3cZkX8q7GM-IexI5y25l6cIQboahZG8bU21Wbe103RdJp19JDT8ODhufsgg244OS0kNA8cjM-meSsGBTSDNw/s320/xml_3.PNG)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-YXSSqEN6Bl31yJLSHECnACPUOtO1Gk6QZKcMswuFIaWVYCvpdXM5qPXf92nRPLaAoijY-dBi3tG9mzVS6PEc2Kg2lclUosT6zwIiWeTc1Y_10PirrD6F7cXKkHmiWhdAORf-YhxF6M/s320/xml_4.PNG)
Step 7: Use the Command "End XML Session"
Step 8: Save the task & Run.
Please refer the below screen shot code for your reference.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFLiegK9zc52PEeVrOJHorLqRwQmhLMiK_65g1PmN3OgtzIIWVgETuZ_cft55nyzShJiM0hbLFaJM6QiluCItr7RCup3apKDZxr3n3KLV56K0ScG-oDq8VEYx3qwNfMTgwpCDRn3cpybE/s640/xml_5.PNG)
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