Tech Support Corner: Sharing XML File Data With Other Systems

5 min read

Oct 22, 2020 2:00:00 PM


A question our tech support engineers get asked quite regularly is how to take data stored in an XML (eXtensible Markup Language) file and share it with other systems such as OPC clients or servers, databases, devices or even the cloud.

Continuing our Tech Support Corner blog series, this post covers a high level review of what options are available for integrating XML file data with your other systems. As part of this series, we'll have supplemental posts on each of the options discussed covering how to use them in more detail. 

Screenshot - XML File Format ExampleSo why might you need to access data from an XML file (or XML formatted data streams) with your control or other systems?  One common example that our engineers have encountered is storing data in an XML file that is used to quickly initialize data points in a PLC or other device (with the PLC or device reading from the file). But the applications could be numerous, as the XML file format is commonly used to store configuration information for devices and software, as well as, some systems using XML to store process data.

Or, since many web-based and applications may exchange data via an XML or JSON payload format, integrating such applications with other systems is also a common need. The same methods used to extract data from an XML file can be easily adapted to consuming data from such applications.

Regardless of the specific data in your XML file, what is more important is what you want to do with that data, since this will determine the best method for extracting that data and making it available for use in your specific project.  Do you need to log the data to a database?  Or do you need to push the data down to a PLC via OPC server?  Or maybe your SCADA system is an OPC client and need to incorporate the XML data for visualization or other operations.

Integrating XML Data using Cogent DataHub

You may have seen us discuss the Cogent DataHub in the past, either in prior posts or in videos, and the wide array of capabilities available.  To that end, since the Cogent DataHub can perform so many different operations, it is a natural option for extracting XML data for integration with other systems.

Diagram - Cogent DataHub Capabilities
Some of the key functions that can facilitate that integration include:

DataHub's ability to bring all data from virtually any source and any protocol, into a single, unified data set is an excellent fit for integrating XML data with as many other systems as possible. And the actual XML data extraction and parsing is straightforward using DataHub's integrated scripting engine.

Example - DataHub XML File Load Scripting
Once the XML data is loaded and parsed, it's available as a dataset for use with any of DataHub's supported system interfaces or functions.

Example - DataHub XML File Parsing Script

Integrating XML Data with Custom OPC Client Applications

Or, perhaps, you are currently building your own custom .NET application and you find out that a new requirement.  The custom application needs to be able to extract data from XML files and push that data to an OPC server.

Screenshot - .NET Example Code for Defining a Class for XML DataOf course, the XML data extraction is relatively standard when using .NET (or most other development environments, for that matter) but building an OPC client interface from scratch is another matter. Using an OPC client development toolkit, though,  allows efficient development/coding without having to learn, understand and implement the entire communication stack.

This approach allows the developer to focus on the source of the data (the XML file, in this case) and data processing and shaping instead of writing a communication stack, allowing the data to be easily integrated into existing custom applications and/or add a layer of abstraction to the underlying source or destination of the data.

Screenshot - Sample .NET Code Snippet Assigning XML Data Fields
The OPC Data Client is a good option for rapidly adding an OPC UA, OPC DA, OPC A&E and/or OPC XML-DA client interface to your custom application.  It provides an easy method for adding the connectivity for your OPC server while you implement the XML extraction with your custom code.

OPC Data Client enables rapid OPC client creation

Integrating XML Data without Scripting

While custom code and scripting is a powerful and flexible option, it's not uncommon for users to need off-the-shelf solutions that don't require the knowledge or ability to script certain operations.  As such, having to using scripting for XML extraction isn't always a viable option for such users.  If you're one of those users, the OPC Router is a good option for integrating XML data since it provides script-free parsing of XML files.

Screenshot - OPC Router XML Data to OPC Visual Workflow
And, once the data has been extracted from the XML files, OPC Router can share it with a variety of other systems including OPC clients and servers, databases, web services and more through one of it's many supported interfaces.

Infographic - OPC Router Functions
So, to close, there are a number of approaches you can take to sharing your XML data, regardless of the source or values that are contained in that XML file or data stream.  Determining how you need to use the data once it is available and the capabilities of those implementing the solution are key variables in what method will work the best for you.  Stay tuned for more specifics on each method in our follow-up posts.

And don't forget to subscribe to our blog to not only be notified of our supplemental XML extraction posts as they are available but to find out about more relevant technical topics applying to industrial process automation and solving related challenges.  Want to chat with one of our experts on the how to get started integrating your XML data?

Ask one of our experts how to get started integrating XML data

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