LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML formatting

Hi Hope all is well, I have an issue creating an xml file for a database data harvester. I had initially tried EasyXML and got the results i was looking for (vi used xmlFormatokdclist5 , file created Correctformat.png) with the formatting perfect.

The issue was i had written the code in labview 2022 and the vi was to run on a 2013 and version 8.6 machine. I then tried using the xml flattening and xml file vi in place of the Easyxml, but the formatting is miles off now and i cant seem to find a way to get it to look the way it should.

 

Correctformat.png is the way i want it and using xml flattening i'm now getting none of the labels to link up.

Snapshot1 is a snap of the cluster used, Snapshot2 is a snap of the vi that doesn't format and Wrte Evalution Results File is the vi that doesn't give the correct formatting.

(ive had to send screenshots of the formatting as they couldn't send)

 

I've had a look at some posts  

https://forums.ni.com/t5/Example-Code/Cluster-to-Xml-Xml-to-Cluster/ta-p/3511062

nothing seems to show how to actually create and save an xml file.

Could someone tell me please how i would go about creating an xml file from a cluster and save the file.

 

All help is much appreciated

 

 

0 Kudos
Message 1 of 5
(472 Views)

Hi Ive tried altering the code at ;

https://forums.ni.com/t5/Example-Code/Cluster-to-Xml-Xml-to-Cluster/ta-p/3511062

 

by deleting the output cluster as i didn't need it and by adding write to XML File .vi, this produces a file that looks to be close to what i had. So i tried adding in my cluster to the main form :

1 i deleted the cluster on the block diagram of the original cluster and also the ref.

2 i created a vi server reference from my cluster and a ref from the vi server reference.

 

When i ran the vi only the basic header tags were created nothing from the cluster ported through. I deleted my cluster/ ref and reinstated the original cluster and created a new vi server reference and ref for the original cluster this works ??

 

Is there a reason i cant get my cluster recognised...

 

 

thanks for looking

0 Kudos
Message 2 of 5
(453 Views)

@Chizzy42 wrote:

Hi Hope all is well, I have an issue creating an xml file for a database data harvester. I had initially tried EasyXML and got the results i was looking for (vi used xmlFormatokdclist5 , file created Correctformat.png) with the formatting perfect.

The issue was i had written the code in labview 2022 and the vi was to run on a 2013 and version 8.6 machine.


Getting your code to run on LabVIEW 2013 should not be a problem, as EasyXML is supported back to LabVIEW 2011. 

 


I've had a look at some posts  

https://forums.ni.com/t5/Example-Code/Cluster-to-Xml-Xml-to-Cluster/ta-p/3511062

nothing seems to show how to actually create and save an xml file.

Could someone tell me please how i would go about creating an xml file from a cluster and save the file.


Sorry, I didn't read this all the way through.  There is another XML parser on the LabVIEW Tools Network, called NI GXML.  I tried EasyXML when it was first released, kind of liked it, but wanted something that didn't require "Write all at once" and "Read all at once".  I found GXML, which seemed to be released in "source" form, so I made a version for myself that allowed me more "flexibility".  You might consider taking a look at it, and see if you can adopt it to your needs.  It states it is made for LabVIEW 2010 and higher, but if you have a LabVIEW 20xx system where xx is relatively small (like 10 or 11), you may be able to "Save for Previous Version" and go back to LabVIEW 8.6.  Then you can see if you can "patch" anything that doesn't work with that (very old) version.

 

I'll try to send you a Private Message on the Forums ...

 

Bob Schor

0 Kudos
Message 3 of 5
(426 Views)

@Bob_Schor, I noticed your comment about EasyXML and the shortcoming of "write/read all at once".  I might be misinterpreting, but I may have had an issue similar to yours back in about 2014 where I wanted to wrap/unwrap some XML to/from a nested cluster, but do it in stages since different layers of a protocol were in play.  I forget the details now, but Jim Kring pointed out a feature (at the time I thought it wasn't fully documented) that allowed you to tag a cluster with a #XML in its name that facilitated this.  Is that the sort of limitation you are describing?

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 4 of 5
(402 Views)

As I recall, I was "rewriting from scratch" a 1000-VI totally-undocumented LabVIEW Real-Time routine used to study sound localizations in medium-sized behaving (or mis-behaving, at times) primates of the BME student variety.  I had two State machines running, one on the Host that basically ran the UI, which open an Excel Workbook and ran the various test sequences (which involved moving a speaker mounted on a 2-DOF robotic arm that positioned the speaker 2 meters from the "test subject" with radial arm that could be positioned from -30 to +30 degrees of azimuth and at a vertical height corresponding (if I remember correctly) -20 to +20 elevation with respect to the subject's ears.  The Robotic Arm was driven by an Industrial Controller (Ladder Logic, anyone?), but was mostly used to position the speaker at various positions.

 

A PXI system (also running a State Machine) handled the delivery of the various sound patterns, the "light" cues (the subject was in an unlit anechoic chamber, with a laser target fixation spot that "went out" when he/she was supposed to point a laser (which became illuminated) at the perceived Target location, with results saved in the Excel Workbook.

 

During my rewrite, I wanted to "Track" the two State Machines and have some "structure" to the record to help me figure out "bugs in the code" (I must confess there were a few).  I hit on XML to write a record each time a State was entered, noting whether from Host or Target, the time (based on a millisecond clock started when the Experiment started), and any "parameter" passed into the State.

 

This code was heavily used for about 5 years, but the lab has been shut down for slightly longer than that, so I don't remember all the details.  But I was clearly writing an "Array of State Clusters", but wanted to do this one cluster at a time.  I started with EasyXML, and figured out (Jim may have helped me here) and managed to write the Array one element at a time, but it was awkward.

 

Then I discovered someone at NI had put on the Tools Network something called NI-GXML, which included the Source code.  So I "extended" the functionality and added a few additional functions and had what I wanted -- a system where I would open an XML output file, write a bunch of stuff, open an Array of Clusters, write them one-at-a-time, close the Array, write a few more things, then close the XML file.  Worked fine.

 

I've used it a few times more for logging/debugging, but sometimes a plain text file created by Write Delimited Spreadsheet works just as well for simple logging-during-development ...

 

Bob Schor

0 Kudos
Message 5 of 5
(350 Views)