Tech Support Corner: Sharing XML Data With OPC Router

7 min read

Nov 12, 2020 2:00:00 PM


If you're following our blog posts on integrating XML data, we're discussing methods our tech support team suggests when asked how to integrate XML (eXtensible Markup Language) data with other systems such as OPC clients or servers, databases, devices or even the cloud.

Continuing this discussion on Integrating XML Data (part of our continuing Tech Support Corner blog series), this post covers how to integrate XML data with a variety of other systems including OPC clients and servers, databases, IIoT and more using the OPC Router. 

Xml_logo.svgIn case you haven't been following our other posts (bear with me, if you have been), I want to review a few items that are central to integrating XML data regardless of the method you use. Namely, there are many reasons you might need to access data in an XML format and share it with other systems. For example, XML is often used to quickly initialize data points in a PLC or other device. Common applications also include reading and integrating stored configuration information for devices and software or reading process data that some devices provide via XML.

Web-based applications also commonly exchange data using an XML payload format. No matter what the data is and where it's coming from (aside from it being in an XML format), your ultimate goal for the data once you have accessed it is the most important question.

This post focuses on the need to take XML data and share it with different systems that OPC Router can connect to using its array of different interfaces and easy visual workflow configuration.

Integrating XML data with other systems (including IT and OT)

If you're not familiar with OPC Router, it is a highly flexible software tool facilitating integration of a host of different industrial, business, and IoT data sources. And OPC Router does this via intuitive drag-and-drop visual workflows designed to reduce engineering time and risk for Industry 4.0, IIoT, and Digital Transformation applications.

The OPC Router provides an out-of-the-box connector to handle integrating XML data with no custom code or scripting required (though scripting is an option in OPC Router for systems that do not support an out-of-the-box interface available in OPC Router). Some examples of out-of-the-box connectors that are available in OPC Router include OPC UA, OPC DA, SAP, REST, MQTT, ODBC and  more. 

How to use OPC Router for XML data integration


1. Configuring a plug-in for the destination of the data

Starting in a slight reversal of what you might anticipate, the first step in integrating XML data using the OPC Router is configuring the desired plug-in for the system with which you need to share the XML data. For the purposes of this post, let's say we want to push the XML data values to an underlying OPC UA server such as TOP Server or OmniServer.

To that end, we would need to configure a new OPC UA Plug-in in OPC Router to act as a client to that OPC UA server where the data will be written.

Screenshot - OPC Router OPC UA Plug-In TreeView

You'll configure the OPC UA Plug-in with a name as well as the correct Endpoint information, log-in credentials and security options supported by your server (if applicable) to allow a connection to your OPC UA Server. Test the connection to make sure the server can be reached with your defined settings.

Screenshot - OPC Router OPC UA Plug-In Properties

2. Creating a new Connection and File Trigger in OPC Router

The next step is creating a new Connection in OPC Router to represent the transfer of the XML data from source to destination.

Screenshot - OPC Router New Connection
Then a new File Trigger needs to be added to the Connection (assuming the XML data you are integrating is in an XML file).

Screenshot - OPC Router New File Trigger

The File Trigger is where you'll specify the file name and location of the XML file you want to integrate data from. Wild card characters can be used for the file name in cases where subsequent XML files will follow a naming pattern (for example, 1File.xmla, 2File.xmlb, etc.).

Screenshot - OPC Router File Trigger Properties

3. Adding and configuring the XML XPath Transfer Object in OPC Router

Now we need to add an </> XML/XPath Transfer Object to the same Connection and configure it. This transfer object will be used to parse the XML file and create outputs based on the elements available in the XML file.  If you're not familiar with what an XPath is, an XPath is essentially a mapping to a specific attribute in an XML file.

Screenshot - OPC Router XPath Transfer Object

Take the following XML file, for example.  It has a main Element called "MachineSetPoints" with a defined format of attributes and sub-elements for each machine. Any number of machines following the same standard format could be accessed using the same XPaths.

Example - XML Data File

From that XML file, the XPath entries in the XML Transfer Object in OPC Router would look like the following:

Screenshot - OPC Router XPath Configuration

When filling out the X-Path Items be sure to test out each X-Path Expression to ensure proper naming. This is done my Pasting a copy of the XML Contents into the space provided and then selecting a X-Path Item and seeing the number of matches. Alternately, here are some additional resources we've found useful in determining the proper syntax for XPath entries and testing them:

An XML Item will need to be created for each XML Element in your file along with its corresponding X-Path. For additional reference, there are many methods of expressing an X-Path which can be referenced in the OPC Router help manual or, for more generic path expression information, click here.

4. Selecting OPC UA tags to write to in OPC Router

The next step is adding an OPC Data Access Transfer object (as the destination for your data) to the existing Connection by drag-and-drop like with the other objects we've added.

Screenshot - OPC Router Data Access Transfer Object

Then we open the OPC Data Access Transfer object and select the OPC UA plug-in configured in the first step as the "OPC access data" field selection for accessing the OPC UA Server. This allows us to browse for and add all OPC UA items that the XML data will be written to.

Screenshot - OPC Router Data Access Transfer Object Configuration

5. Mapping XPath items to OPC UA tags in OPC Router

Now that the XML data is configured as variables and the desired OPC UA items are selected to receive the XML data values, it's time to map them to together. This is accomplished by connecting the XPath items to the corresponding OPC UA item you want that particular value to be transferred to.

With the visual workflow editor in the Connection, this is simply a matter of dragging a connection from the source XML XPath item to the destination OPC UA item.

Screenshot - Mapping XPath items to OPC UA items in OPC Router

5. Activating the runtime and testing the XML data transfer in OPC Router

Last but not least, we need to set the configured Connection and associated objects "Productive" to upload this configuration to the runtime service engine.

Screenshot - Setting OPC Router configuration Productive

Now that we're successfully parsing the XML data into the OPC UA items, we can verify that the data from the XML file is being transmitted successfully by pulling the connection up in the State view in OPC Router using the bottom "State" tab on the far left side. This allows us to monitor the data transfers when the Connection is triggered.

Screenshot - Monitoring data transfers with the State view

So, to close, a visual drag-and-drop workflow and variety of interfaces makes it easy to extract XML data and share it with almost any other system you might need to access that data. While we specifically focused on transferring the XML data to an OPC UA server, similar methods would apply for most other target systems supported by OPC Router. If you haven't already tried the OPC Router, the free trial version is available here.

And don't forget to subscribe to our blog to find out about more relevant technical topics applying to industrial process automation and solving related challenges.  Want to try integrating your own XML data using the OPC Router?

Integrate XML Data with the free OPC Router trial

Kevin Rutherford
Written by Kevin Rutherford

Software Toolbox Technical Blog

We're engineers like you, so this blog focuses on "How to" appnotes, videos, tech team tips, product update announcements, user case studies, and other technical updates.  Subscribe to updates below. Your feedback and questions on posts are always welcomed - just use the area at the bottom of any post.

Subscribe to our Blog

Recent Posts

Posts by Topic

See all