Skip to content
Homes32 edited this page May 14, 2022 · 2 revisions

XMLAdd

Add a new element/text/attribute to an XML file.

To update an existing element/attribute you must use the XMLUpdate command.

Syntax

XMLAdd,<Operation>,<XMLFile>,<XPath>,<Type>,<Name>[,<Value>]

Arguments

Argument Description
Operation One of the following:
Insert - Insert a node at the the beginning of the XPath.
Append - Append a node to the end of the XPath.
Subnode - Add a new subnode to each XPath in the document.
XMLFile Full path to the .xml filed to edit.
XPath XPath (XML Path Language) query used to insert the Attribute/Element.
Type XPath type [elem
Name Value Name.
Value (Optional) Value

Return Codes

None.

Remarks

If the command fails the build will halt.

For more information about using XPath syntax check out this XPath Tutorial.

Related

XMLDelete, XMLRename, XMLUpdate

Examples

Example 1


// Add a Subnode called GUIConfig under GUIConfigs
XMLAdd,SubNode,%config.xml%,"NotepadPlus/GUIConfigs","elem","GUIConfig",""

// Insert a new attribute into an XML file.
XMLAdd,Insert,%config.xml%,"NotepadPlus/GUIConfigs/GUIConfig[not(@name)]","attr","name","DarkMode"

// Append an attribute to the DarkMode attribute
XMLAdd,Append,%config.xml%,"NotepadPlus/GUIConfigs/GUIConfig[@name='DarkMode']","attr","enable","yes"