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
| Input | Type | Required | Default | What it is |
|---|---|---|---|---|
| Path | File | No | XML file (or use xml). | |
| Parent XPath | String | Yes | XPath of the parent node(s). | |
| Name | String | Yes | Element name. | |
| Text | String | No | Element text. | |
| Attributes | Dictionary | No | Attributes to set. | |
| Save to | File | No | Save to another file instead of overwriting. | |
| Position | String | No | end | end or start: last or first child of the matched node; before or after: next to the matched node, as its sibling. |
| If exists | String | No | insert | When the parent already has a child with this name (end/start only): add another, skip, or replace the first one. |
| XML | String | No | XML text to change instead of a file; the result is in the xml output. | |
| Reference child | String | No | With 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. | |
| Namespaces | Dictionary | No | Namespace 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. | |
| Session | String | No | Work 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
| Output | Type | What it is |
|---|---|---|
| count | Number | Elements inserted. |
| xml | String | The XML after the change. |