XML Add Element
XML Add Element
Section titled “XML Add Element”Type: xml-add-element · Package: XML Activities v1.0.0 · Output: string
Adds a new child element to the first node that matches an XPath, and returns the modified XML. Use it to build or extend an XML document: add a line to an invoice, a field to a record.
How it works
Section titled “How it works”Locates the parent element with xpath, creates within it a child element called elementName (with optional elementValue and attributes), and returns the modified XML as a string. Save it with Write XML.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
xml | expression | The XML text. |
xpath | expression | XPath al elemento padre. |
elementName | expression | Nombre del nuevo elemento. |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
elementValue | expression | Contenido de texto del nuevo elemento. |
attributes | expression | Dictionary of attributes to put in the new element. |
Output
Section titled “Output”Returns a string with the modified XML.
Example
Section titled “Example”Add a <Observacion> field inside <Factura>:
XML Add Element xml = = xml xpath = "//Factura" elementName = "Observacion" elementValue = "Revisado automáticamente" → output: xmlNuevoWrite XML path = = ruta content = = xmlNuevoRelated activities
Section titled “Related activities”- XML Set Value — change the value of an existing element.
- Write XML — save the result.