AddNode will add a user-defined node into the XML document structure of a specified XML file. This can be useful for long-term data storage and modification.
The process accomplishes this by first loading the XML document structure from the specified file, and then attempting to add the node. It uses the provided XPath expression to locate the parent node to add a child to and then creates the child; additionally giving the new node any user-specified XML attributes. Afterwards, it saves the XML structure back to the file.
If the specified XPath cannot be evaluated to find a parent node, then an exception is thrown with the message “Parent node path <your xpath expression> could not be found.” This could mean that the parent node you are trying to locate does not exist or that the XPath expression specified does not target a node or is invalid.