Using XML Data in LabVIEW Just Got Easier

Posted on Saturday 1 March 2008

As I've mentioned before, using XML data in LabVIEW is way too hard.  And, according to this poll, 7 out of 10 LabVIEW developers think so, too.  LabVIEW's built-in XML schema and support functions are not at all useful for generating and parsing XML schemas defined by others.  And, the various tools available to LabVIEW developers for generating and parsing XML schemas defined by others are not easy to use.

For example, there's really no simple and maintainable way to write the code necessary to generate and parse the following XML:

<Person Nationality=”US”>
  <Name>
    <First>John</First>
    <Last>Doe</Last>
  </Name>
</Person>

The existing tools require understanding way too much about the details of the XML language (e.g., DOM) and get in the way of the average developer doing useful work with XML data.  For examples, this is the code required to read only a single attribute of an XML entity:

DOM Example

When I think easy, I imagine a tool that will allow the developer to:

1.) define a simple LabVIEW data structure that is analogous to an XML data structure of interest and
2.) use it to generate and parse the XML data.

For example, generating and parsing XML data in LabVIEW should be as easy as creating a cluster:

cluster_to_xml.png

The good news is that JKI Software has just released such a tool that lets you work with XML by simply creating a cluster in LabVIEW.  For example, you can create an XML playlist with just one VI and a cluster, as show in the screenshot, below.

Playlist Generation Example

And, parsing XML is just as easy, as you can see in this example that downloads the LAVA RSS feed and parses the data into a cluster.

RSS Reader Example

This new tool is called the EasyXML Toolkit for LabVIEW and is a low-cost ($39 introductory price) toolkit that can be installed using VI Package Manager.  And, you can even download the demo for free, using VIPM.  Now, that's easy.

30 Comments for 'Using XML Data in LabVIEW Just Got Easier'

  1.  
    March 2, 2008 | 5:11 pm
     

    I prematurely hit the “publish” button, yesterday, when I released this blog article. The result was that the article sounded too much like a cheap ad and not enough like an informative article. So, today, I updated the article with some more useful information. Ya, this article is still a plug for EasyXML, but I hope you find it informative :)

  2.  
    Alex
    March 3, 2008 | 7:24 am
     

    Nice tool! Unfortunately I’m about to publish a clone of it for free ;)

  3.  
    March 3, 2008 | 8:20 am
     

    Alex: Don’t let us stop you :) But, please give our free demo a try. We’ve worked hard to make sure that EasyXML is very robust, full of many nice usability features (e.g., pretty-print, support for attributes, graceful handling of comments, etc.), and is of the high-quality you’d expect from commercial grade software. I happily take on the challenge of trying to win you as a customer :)

  4.  
    Alex
    March 3, 2008 | 9:14 am
     

    Do you manage attributes? Like this:

    [xml comments filtered out by blog]

  5.  
    March 3, 2008 | 9:24 am
     

    Alex: Yes, sorry, the blog does filter anything that might look like XML, since that might be a security issue when the HTML is rendered. You can read more about how attributes are handled in the documentation, here. Basically, attributes are achieved by placing a cluster named “#attributes” as the first cluster element of the xml element cluster.

  6.  
    Oskar
    March 4, 2008 | 1:13 pm
     

    Alex,
    Could you provide a link to your free toolkit? Curious about that one as well.

    Jim,
    Would it be possible (technically) to have the XML parser generate a cluster automatically. So that you can get that without, in advance, knowing what XML data you are getting. I guess that would be a variant then? Wonder how you would display that??

  7.  
    March 4, 2008 | 1:25 pm
     

    Oskar: We could, conceivably parse the XML data without knowing the LabVIEW data structure, in advance — yes, putting this in a variant would make sense. In a future version of the software, we are considering adding a utility that would allow you to create a cluster from the XML string, in order to reduce the work required to create a VI that can parse an XML string. We’ve got a lot of additional ease-of-use features that we’re working on, too :)

    Alex: I’m curious to see your tool, too.

  8.  
    Vincent
    March 6, 2008 | 12:49 am
     

    Its nice to know other people have the same needs and are working towards a more robust parser. I remember a year ago, I couldn’t find any discussions or code that could parse XML into a LabVIEW cluster. I actually spent some time developing my own vi to do just that. I’ve finally got it to a point where I think others could use it and improve upon it. However, I have no idea where I could share it.

  9.  
    Ton Plomp
    March 6, 2008 | 2:14 am
     

    On LAVA you can post such info at the CR in development portal.
    or as a new thread.

    Ton

  10.  
    March 6, 2008 | 10:31 am
     

    Vincent: As Ton mentioned, the LAVA Code Repository is a great place to share your code. But, if you don’t want to do something that formal, you can just post your code to the LAVA discussion forums for people to see.

  11.  
    Jon McBee
    May 16, 2008 | 12:56 pm
     

    What is the difference between the trial version of the software and the purchased version? I cant seem to find an online comparison of the two.

  12.  
    May 16, 2008 | 1:17 pm
     

    Jon: the trail version of EasyXML is full-featured, but will present a dialog, telling you that it is a demo version.

  13.  
    Eli
    May 29, 2008 | 1:00 pm
     

    Where did you find the first (orange) VI that converts the XML string into a DOM parser session? I can’t find it anywhere…

  14.  
    Ton Plomp
    May 29, 2008 | 1:35 pm
     

    I think it’s part of the Internet toolkit

    Ton

  15.  
    Eli
    May 29, 2008 | 8:04 pm
     

    I though it was too but I cannot find that specific one anywhere. I have all the other ones.

  16.  
    June 1, 2008 | 10:54 pm
     

    Eli: That’s a custom VI that I wrote. It’s part of what makes it hard to use XML in LabVIEW, I guess ;) Basically, it writes the string to a temp file and then uses the LabVIEW Internet Toolkit’s Read XML from File functionality to read the temp file, which is then deleted.

  17.  
    Eli
    June 2, 2008 | 3:02 pm
     

    Thank you Jim. Thats what I though was happening and exactly what I wanted to avoid.

  18.  
    John
    July 7, 2008 | 6:42 am
     

    I was just wondering which versions of Labview is this toolkit compatible with. I am creating a application were the toolkit would be a great timesaver but I am using Labview 6.1. Is this too old a version?

  19.  
    July 7, 2008 | 8:08 am
     

    John: EasyXML works on LabVIEW 7.1 or greater. You can find all of the system requirements here: http://jkisoft.com/easyxml/requirements/.

  20.  
    Matthias
    October 21, 2008 | 8:24 am
     

    I was actually searching for a way to save and read the data of LVOOP objects to a text file, that can be edited with a simple editor. Basically it is meant as a settings file to initialize my objects. I cannot easily download with VIPM with our firewall, so could you please answer my question: can this tool also handle object clusters? Or is there any other way to do it?

  21.  
    October 21, 2008 | 3:41 pm
     

    Hi Matthias: EasyXML does not currently support LVOOP object data. However, it might someday ;)

  22.  
    Matthias
    October 22, 2008 | 7:44 am
     

    Hi Jim: thank you for the prompt and straightforward answer. After more searching I finally found that LabVIEW 8.6 presumably offers flattening classes to XML-string. (zone.ni.com/reference/en-XX/help/371361E-01/lvconcepts/using_classes/). So far I am using LV8.5 which does only allow the flattening objects to string function (which is not really useful for editing outside LV).

  23.  
    Evan
    February 19, 2009 | 7:28 pm
     

    Jim, it appears as though your EasyXML kit was released around a year ago? I saw some mention in the comments of this posting that you were toying with the idea of building a tool to convert from XML to LV Data Structures.

    I am also interested in this. There is a good chance that I will use LabVIEW for an upcoming event recorder. The catch is that all events are written in a specific XML schema. There is a 200 page document, and a 200 line XSD file (https://pslcdatashop.web.cmu.edu/dtd/).

    It would be nice if there was a simple tool to parse the XSD file and create a set of clusters. Then I would be much more inclined to obtain your EasyXML kit. The pain for me is that I may need to manually (read: with errors) create the data types.

    Cheers,

    Evan

  24.  
    February 19, 2009 | 8:36 pm
     

    Hi Evan, Thanks for the feedback. Yes, an XML to LabVIEW data structure converter would be great. It’s on our roadmap for a future version. Beyond that, I can’t make any promises. Cheers.

  25.  
    Isaac Fayad
    February 22, 2009 | 2:31 am
     

    Hello Jim Kring ;
    Could you please tell me where could i find the second block in Figure 4 after “xml string” block. I searched in Function Palette and i could not find any thing. I have also the the Internet Toolkit installed on my PC.
    thanks

  26.  
    February 22, 2009 | 4:19 pm
     

    Isaac: The second block is part of the EasyXML Toolkit for LabVIEW, a commercial add-on from JKI.

  27.  
    Silvester
    March 30, 2009 | 6:07 am
     

    Hi Jim,
    in this thread, you talk about an XML to LabVIEW data structure converter.
    I think this means, that the Class-Structure hasn’t to be created by hand. So changes in the XML-Structure result in changes of the Labview data structure.

    Do you have a rough release date for this feature?

    Silvester.

  28.  
    March 30, 2009 | 7:38 am
     

    Silvester: We don’t have a release date for the XML to LabVIEW data structure converter. But, we’ve been getting a lot of requests for it and it’s definitely on our roadmap.

  29.  
    Scott Jordan
    September 14, 2010 | 12:55 pm
     

    Jim, Add me to the chorus of folks who want a subVI which converts incoming XML to a cluster without foreknowledge of the LabVIEW data type. I can see all sorts of uses for this. If a beta version becomes available, I’d happily serve as a guinea pig. I want it rather badly!

  30.  
    Ednei
    April 20, 2012 | 5:12 am
     

    Thank you this was a lot useful :)
    If you would implement a XML to LabView Data conveter from where would you start it?
    I would like to have something that coulbe drive by a dtd file.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post |

 

Bad Behavior has blocked 1123 access attempts in the last 7 days.