-
Notifications
You must be signed in to change notification settings - Fork 11
XMLAdd
Homes32 edited this page May 14, 2022
·
2 revisions
Add a new element/text/attribute to an XML file.
To update an existing element/attribute you must use the XMLUpdate command.
XMLAdd,<Operation>,<XMLFile>,<XPath>,<Type>,<Name>[,<Value>]
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 |
None.
If the command fails the build will halt.
For more information about using XPath syntax check out this XPath Tutorial.
XMLDelete, XMLRename, XMLUpdate
// 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"