Top
Top
LibraryEASYProcess Reference ManualProcessesServicesXmlWorkshopAddNodeValue

AddNodeValue Overview

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.

Exception

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
Workshop:XmlWorkshop
Service:AddNodeValue
Inputs
FileNameThe complete name, extension, and path to an XML file which is to have its contents edited by this service

NodePathAn XPath expression defining the XML node within the file which is to have an value added to it

NodeValueThe new value that the specified node should attain

AddNodeValue Use Examples

Basic AddNodeValue Use

AddNodeValue Service Input

Process Structure

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.

Output

FileBefore

AddNodeValue

FileAfter


Powered by EASYProcess (© 2019 K-Rise Systems, Inc).