Update XML Activity
The Update XML activity modifies specific elements or attributes within an XML document or string. It enables users to specify an XPath expression to target a particular node and provide a new value for that node. This activity is crucial for dynamic XML manipulation in automation workflows.
| Field | Description | Requirement |
|---|---|---|
| File name | The path to the XML file to be updated. | Optional |
| Xml string | The XML content provided as a string. If this field is used, the File name field is not required. | Optional |
| Xpath expression | The XPath expression to reference the target element or attribute within the XML content. | Required |
| Filter | Specifies whether to access an ELEMENT or an ATTRIBUTE within the XPath. | Required |
| New value | The new value to be assigned to the referenced element or attribute. | Required |
| Prefix | Defines a namespace prefix used in the XML file. | Optional |
| Uri | Provides the URI for the first defined namespace prefix. | Optional |
| Prefix2 | Defines a second namespace prefix used in the XML file. | Optional |
| Uri2 | Provides the URI for the second defined namespace prefix. | Optional |
| Prefix3 | Defines a third namespace prefix used in the XML file. | Optional |
| Uri3 | Provides the URI for the third defined namespace prefix. | Optional |
| Result variable name | The name of the variable that will store the updated XML content. | Required |
Action Types & Examples
Updated XML Content
- Format: string
- Example Result:
"<Invoice><Return_ID>135672</Return_ID><Store_ID>9876</Store_ID><Store_Name>BELGE</Store_Name>...</Invoice>"
Implementation Examples
Field Setup - File name: C:\Users\Alice\Documents\invoice.xml - Xml string: <string name="string_name">text_string</string> - Xpath expression: //Invoice/Store_ID - Filter: ELEMENT - New value: 9876 - Prefix: ds - Uri: urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 - Prefix2: cac - Uri2: urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2 - Prefix3: caa - Uri3: urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 - Result variable name: updatedXmlContent
Execution Parameters - File name: myXmlFilePath - New value: newStoreId - Result variable name: updatedInvoiceXml
Technical Notes
If both the
File nameandXml stringparameters are provided, theXml stringcontent will take precedence, and the activity will operate on the provided string rather than the file. Prefixes and URIs are essential for correctly resolving elements and attributes within XML documents that utilize namespaces. TheFilterparameter ensures precise targeting of either an XML element or an attribute at the specified XPath.