LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML streaming

Solved!
Go to solution

I was informed today that my client wants their data in XML format. Smiley Surprised I need to either write data continuously to an XML file at 1hz or I need to convert a just-completed TDMS file to XML. The TDMS files can have as many as 250K data points. Has anyone done anything like this? I love TDMS and the existing XML vi's are meager and don't offer much in the way of flexibility and functionality. Any thoughts? Thanks in advance.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 1 of 4
(2,820 Views)

It's not difficult to write to xml. Basically you just format your numbers like

<Tag>%f</Tag>

And write this to the file.

 

The header can also be hardcoded as a string const.

 

Felix

0 Kudos
Message 2 of 4
(2,783 Views)
Solution
Accepted by topic author PaulG.

The thing with streaming XML is that the file will not be valid XML unless all tags are properly closed. Some applications tolerate that, but it is non-standard, so other applications will refuse to load the files. XML files have tags that enclose the entire payload by definition, so closing tags need to be written (and previous closing tags removed) every time you append to the file. XML engines like Xerces ensure this by always writing the entire file, instead of incrementally adding something to it. That is usually not an option for streaming applications, because performance heavily degrades with the file growing in size. Since your acquisition appears to be finite, it'll come down to whether that still works for the amount of data you're storing. If it doesn't, you could for example write some code that overwrites the last few characters in the file (in order to stomp existing closing tags), or you could convert from TDMS after acquisition.

 

Hope that helps,

Herbert

 

0 Kudos
Message 3 of 4
(2,743 Views)

Converting a completed TDMS data file to XML sounds like the best idea. Also, we may be able to get away with leaving the files as-is in TDMS format since TDMS can be uploaded directly into Excel. The only problem is that this company wants everything in XML format for company standards purposes. The powers-that-be are still out making a final decision.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 4 of 4
(2,712 Views)