AddNodeValue will add an XML text node to a targeted XML node within 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 inner text node. It uses the provided XPath expression to locate the target node and then attempts to add the new new text node; replacing any previously-existing inner text of that node. 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 “Node path <your xpath expression> could not be found.” This could mean that the targeted node which you are trying to locate does not exist or that the XPath expression specified does not target a node or is invalid.
AddNodeValue Use Examples
Basic AddNodeValue Use
AddNodeValue Service Input
For this example, we have set up the following file, named “test.xml,” in the “C:\EASYProcess,” directory on the local machine.
When run, the AddNodeValue service will load the XML document structure of the given file and add the user-specified node value to the target node, as a (new) text node. In this example, we are simply adding a text node with the value “Hello World!” to a node named “Element” which is a child of “Document.” Here is the same file after the service has run:
For clarity, we have added two LoadFromFile service blocks in order to display what the file looks like before and after the changes.