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

ParentNodePathAn XPath expression defining an XML node within the file which is to be the parent of the new XML node

NodeNameThe name of the new XML node being added

AttributesThis is the container node that contains all the Attribute nodes. It does not accept any input, but you can Right-Click to add new Attributes (Attribute#0, Attribute#1, etc.). Each Attribute node represents a single XML attribute for the new node.

AttributeThe Attribute is a container node which accepts no input, but represents a single XML attribute for the new node.

NameThe name of this XML attribute

ValueThe value of this XML attribute

Outputs
NodeNameThe name of the new XML node that was added to the document structure; this should be the same as the input node.
NodeValueDeprecated; do not use.

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).