Top
Top
LibraryEASYProcess Reference ManualProcessesServicesXmlWorkshopAddNode

AddNode Overview

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.

Exception

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.


AddNode Use Examples
Workshop:XmlWorkshop
Service:AddNode
Inputs
FileName

ParentNodePath

NodeName

Attributes

Attribute

Name

Value

Outputs
NodeName
NodeValue

AddNode Use Examples

Basic AddNode Use

AddNode 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 AddNode service will load the XML contents of the given file and add the user-specified node details into the target location within the file.  In this example, we are simply adding a (new) node named “Element” (with no attributes) as a child of the already-existing node “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


AddNode

FileAfter


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