Skip to main content

Insert node

Add an element, with its text and attributes, under, before or after every element a path finds.

Command in the XML toolkit · id ooa.xml/insert_node · 12 inputs (2 required), 2 outputs

Inputs​

InputTypeRequiredDefaultWhat it is
PathFileNoXML file (or use xml).
Parent XPathStringYesXPath of the parent node(s).
NameStringYesElement name.
TextStringNoElement text.
AttributesDictionaryNoAttributes to set.
Save toFileNoSave to another file instead of overwriting.
PositionStringNoendend or start: last or first child of the matched node; before or after: next to the matched node, as its sibling.
If existsStringNoinsertWhen the parent already has a child with this name (end/start only): add another, skip, or replace the first one.
XMLStringNoXML text to change instead of a file; the result is in the xml output.
Reference childStringNoWith position before or after: insert next to the first child of the matched node with this element name, instead of next to the matched node itself.
NamespacesDictionaryNoNamespace declarations put on the new element, as prefix to URI (an empty prefix is the default namespace); name may then use the prefix, e.g. inv:note.
SessionStringNoWork on the XML of this session (Start session) instead of a file or text; changes stay in the session until End session saves them.

Outputs​

OutputTypeWhat it is
countNumberElements inserted.
xmlStringThe XML after the change.