- Overview
- Cryptography
- Database
- Java
- Python
- WebAPI

Developer Activities
Get XML Node Attributes
linkUiPath.WebAPI.Activities.GetXMLNodeAttributes
Description
linkRetrieves the attributes of an XML Node.
Project compatibility
linkWindows - Legacy | Windows | Cross-platform
Cross-platform configuration
link- ExistingXMLNode - The XML Node whose attributes are to be retrieved. This field supports only
XNode
variables. For more information onXNode
objects, go here.
Advanced options
Output
- Attributes - An
IEnumerable<XAttribute>
variable containing the retrieved XML node attributes. For more information onXAttribute
objects, go here.
Windows - Legacy, Windows configuration
linkProperties panel
Input
- ExistingXMLNode - The XML Node whose attributes are to be retrieved. This field supports only
XNode
variables. For more information onXNode
objects, go here.
Output
- Attributes - An
IEnumerable<XAttribute>
variable containing the retrieved XML node attributes. For more information onXAttribute
objects, go here.
Misc
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
Common
- DisplayName - The display name of the activity.
Example of Using the Get XML Node Attributes Activity
link.xml
files.
.xml
file, converts it to an XML document, retrieves the individual nodes and writes an attribute and a value for each node.
This is how the automation process can be built:
-
Open Studio and create a new Process.
Note: Make sure to place the.xml
file inside the project folder. For this example we used theXMLfiles.txt
. -
Drag a Sequence to the Workflow Designer.
-
Create the following variables:
Variable Name
Variable Type
Default Value
XMLString
String
XMLNodes
**IEnumerable<XNode>
XMLDocument
XDocument
-
-
Drag a Read Text File activity inside the sequence container.
- In the Properties panel, add the name
Read XML file
in the DisplayName field. - Add the value
"XMLfiles.txt"
in the FileName field. - Add the variable
XMLString
in the Content field.
- In the Properties panel, add the name
-
Drag a Deserialize XML activity under the Read Text File activity.
- In the Properties panel, add the variable
XMLString
in the XMLString field and the variableXMLDocument
in the XMLDocument field.
- In the Properties panel, add the variable
-
Place a Get XML Nodes activity after the Deserialize XML activity.
- In the Properties panel, add the variable
XMLDocument
in the ExistingXML field and the variableXMLNodes
in the XMLNodes field.
- In the Properties panel, add the variable
-
Drag a For Each activity after the Get XML Nodes activity.
- Add the value
node
in the Item field and the variableXMLNodes
in the Values field. - Select the
System.Xml.Linq.XNode
option from the TypeArgument drop-down list.
- Add the value
-
Select the Body of the For Each activity and create a new variable:
Variable Name
Variable Type
Default Value
XMLAttributes
**IEnumerable<XAttribute>
-
Add a Write Line activity inside the Body container.
- Add the expression
node.XPathSelectElement("author").ToString
in the Text field. This expression selects the name of the author from the.xml
page and writes it in the Output panel.
- Add the expression
-
Place a Get XML Node Attributes activity after the Write Line activity.
- In the Properties panel, add the value
node
in the ExistingXMLNode field and theXMLAttributes
variable in the XMLAttributes field.
- In the Properties panel, add the value
-
Drag a For Each activity after the Get XML Node Attributes activity.
- To open the activity, perform a double click.
- Add the value
attribute
in the Item field and the variableXMLAttributes
in the Values field. - In the Properties panel, select the
System.Xml.Linq.XAttribute
option from the TypeArgument drop-down list.
- Select the Body of the For Each activity.
-
Drag a Write Line activity inside the Body container.
- Add the expression
attribute.Value
in the Text field.
- Add the expression
- Run the process. The robot extracts an attribute and a value from the nodes, in this case, the name of the author and the book id, and displays them in the Output panel.
Here you can download an example.