Applying XML to Your Test and Measurement Applications
Overview
Learn the basics of XML and how to use XML in your test and measurement applications. This article discusses the fundamentals of using XML and explores a simple data acquisition application to help you understand how to use XML in your application.
Table of Contents
Defining XML
Extensible Markup Language (XML) is a data-formatting framework that makes it easier for you to share data between applications and between computers. XML is more flexible than other markup languages like HTML for two primary reasons -- one, it separates the storage of data from the viewing of data, and two, it provides a way to describe what the data represents. XML is also the foundation layer for the new Microsoft .NET framework. You can read a previous articles titled "Frequently Asked Questions about Microsoft .NET" for more information.
Sharing Data with XML
Being able to separate storing data from viewing data means that, with XML, you can store your data in one format and view that data in many different ways without changing how the data is stored. XML can describe what the data represents, which means that you can describe how to display the data (color, font, and formatting), and what that data represents (waveform acquired from an oscilloscope, alarm indicator value, etc.). Together these benefits allow you to store any data in a single data storage format that you can define to custom fit your applications. You can also access the data in any other application simply by knowing it can read XML files. While this is useful on a single computer for sharing data between applications, the real benefit of this functionality is in a multicomputer environment. This is because XML files are ASCII text, which means that you can easily share these files between both applications and computers using different operating systems connected by a simple Ethernet connection.
Using XML to View Data in Multiple Formats with Different Applications
You can use the following example as a model of how to create an XML file and display the data from that XML file. Assume you have finished acquiring a series of data points from your test platform and completed some basic analysis on this data. Now, you would like to write all of this raw data, along with the analysis, to a file. To output this data to a file, you need to first plan what your XML file should look like. You can think of this planning process as the blueprint for the XML file you are about to build. With this blueprint, or XML schema, you can write all of your data and analysis to an XML file.
A schema file defines how XML file will appear
Being able to custom define fields in your XML file, such as "data," "mean," "max," and "min," is part of the flexibility and power of XML. The only difficulty is the learning curve associated with constructing valid schemas. Thankfully, intelligent development systems such as National Instruments LabVIEW and TestStand provide schemas for you that already describe how your XML data will appear.
Developing Test and Measurement Applications with XML
Assume we are using the data acquisition example described above. Now that you have an XML file that contains all of your data, you will want to apply your data. XML are in ASCII text, which means you can easily display it in any text editor or open it in an XML capable browser, such as Microsoft Internet Explorer. If you want to display this data as more than simple text, you can use anything from database applications, to Web browsers. To read your XML file, these applications need a style sheet. For each way that you want to view the data in the XML file, you need a separate style sheet. This is how the data storage separates from the data viewing.

Using style sheets, you can view the same XML data in many different ways
In this way, you can use one style sheet to display information to your customers, and a different style sheet to present information to your technicians, who might require specific information to debug a problem. You can also use a third style sheet to load all of your data to your enterprise database system.
When performing this task previously, you would need to create three different output methods for your data. Now, by using XML and style sheets, you only need to create one data file that you can view in multiple formats that accommodate your needs. Moreover, you no longer need to know the type of application that will view your data because the end user can build his or her own style sheet to accommodate application needs once you have provided your XML data file.
Choosing Between XML and Other Methods of Displaying Data on Web
XML is already defining company-wide data standards. This makes good use of the XML data format because you only have to design one schema file that everyone can use by applying relevant parts of the schema to fit their application needs. Then, all that remains is to design a style sheet for each view of the data you desire. With this system, your test and measurement applications can easily communicate with every application in your enterprise, and each of these other enterprise applications can create data and display it from any other application.
Conclusion
The biggest difference between using XML to display data to the Web and other technologies is that you must first create a file and use the file to display information on the Web. Thus, using XML to display data on a Web page is similar to using a spreadsheet file and to display the data on a Web page. You should consider using other technologies if your application requires you to maintain control through the Web, view your data as it is acquired, or if you do not want to create text files for your data. Many other technologies for making your data available on the Web are described in the white paper, "Taking Your Measurements to the Web with LabVIEW."
XML offers a good solution for sharing your data across your enterprise and with virtually anyone you want in a convenient and easy-to-use format. Applications such as National Instruments LabVIEW and TestStand have continued to integrate new technologies, like XML, to provide you the technology to make your applications even more powerful. If you would like more information about LabVIEW and TestStand, please visit ni.com/LabVIEW, and ni.com/TestStand.
Reader Comments | Submit a comment »
This documents outlines some ideas for XML
data storage/retrieval but does not give any
examples of solutions. XML support within
labview is pretty poor ("Flatten to XML" is
very hard to use outside of LV and bloats
stored results). Example solution source
code (VI's, XML schemas, reports, ets) for
each topic outlined would answer a lot of
questions.
- Gerard Garrelts, Sensotec. ggarrelts@sensotec.com - Nov 8, 2005
XML Schema Info Needed
Where would one find the XLM schema for data
acquisition. If the big advantage is to share
information, then an open agreed format must
exist.
- Feb 4, 2005
Inset xml code not consistant with text....
The Xmal instance document(inset graphic)
shows the file to be 'Stand-alone'.
Doesnt this imply no schema will be used to
validate the xml instnce document.
However the text description and Block
diagram refers to a schema provided by NI to
aid in creating the xml instance document.
Appears to be an inconsistancy in the
graphic vs the text description.
Also Is it correct to refer to 'valid'
schemas. Unless of course there is a schema
for the schema.
Instance documents are usually refered to
as 'well-formed' and 'validated' against a
schema or DTD.
LME
- Leo Errico, Navair Nadep Jax. erricolm@navair.navy.mil - Jun 8, 2004
I think that at present native LabVIEW is
not realy capable of supporting XML to the
full extend. Nevertheless its a beginning
to help people on their way in using some
primary XML techniques. But if its only a
beginning it would have been better to
point tha out and give links to XML-
tutorials.
In the intro it says Learn the
basics of XML
; well it is very
brief in this:
It's a pitty that the basic vocabulary is
not even showed nor explained, attributes
are not mentioned once......
Especially the part. "Using XML to View
Data in Multiple Formats with Different
Applications" gives a blurred view on the
subject.
First of all the title does not cover the
content, (how can I View data in multiple
formats?: XSL is not even mentioned
anywhere).
Then the article says:
To output this data to a file, you
need to first plan what your XML file
should look like....... With this
blueprint, or XML schema, you can write all
of your data and analysis to an XML file
Here the article is right , but: LABVIEW
DOES NOT ALLOW FOR SCHEMAS OTHER THEN THE
LABVIEW SCHEMA. So designing your XML,
which is usually done by designing a SCHEMA
is not possible or at least very limited.
It suggests you can do all that in
LabVIEW , but in fact you just can not. I
think when starting explaining XML in a
LabVIEW context, NI should point that out
explicitely. Because of this limitation
LabVIEW is not (yet?) capable of dealing
with XML, without employing other toolkits
(which are not mentioned anywhere).
And "flatten to XML" is just a very basic
attempt to provide some XML support: How
can I add my own xml-structure, how can I
use attributes (NOT MENTIONED IN THE
ARTICLE), how can I validate my data, how
can I search in XML-documents, use XPATH
etc etc? All very important and useful
features of XML which are not supported in
LabVIEW and not mentioned in the article.
Why were there no links, where people can
learn about XML. Why are there no links to
XML-toolkits available for Labview (eg.
http://labxml.sf.net), and the msxml parser
of Microsoft or XERCES-parser.
I hope (and expect) that this is a first
step to a full support of XML in LabVIEW
Thijs Bolhuis
- Thijs Bolhuis, University of Twente. t.bolhuis@el.utwente.nl - Dec 3, 2002
Nice Summary, but no how to
This article clarified my basic
understanding of XML and opened my eyes to
its application with NI. However, the
stumbling block with XML is 1) how to write
data into XML format, 2) how to create style
and schema sheets. So far all the XML
articles I've read never go this deep.
Otherwise this article was very clear and
concise! --Thank you
- Stephan DiBiase, Visteon. sdibiase@visteon.com - Oct 28, 2002
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
