Skip to content

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.

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.

ParameterEditorDescription
xmlexpressionThe XML text.
xpathexpressionXPath al elemento padre.
elementNameexpressionNombre del nuevo elemento.
ParameterEditorDescription
elementValueexpressionContenido de texto del nuevo elemento.
attributesexpressionDictionary of attributes to put in the new element.

Returns a string with the modified XML.

Add a <Observacion> field inside <Factura>:

XML Add Element
xml = = xml
xpath = "//Factura"
elementName = "Observacion"
elementValue = "Revisado automáticamente"
→ output: xmlNuevo
Write XML path = = ruta content = = xmlNuevo