Example Code

LabVIEW miniXML Library

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Programming Language

  • LabVIEW G

    Other

  • XML
  • libXML
  • miniXML
  • LabVIEW XML

Code and Documents

Attachment

Description

Description-Separate-1

In a previous document (https://forums.ni.com/t5/Example-Code/Libxml2-Parsing-XML-in-LabVIEW-is-too-slow-or-is-it/ta-p/34926...) TroyK posted an updated version of the LabVIEW libXML library for parsing XML files that greatly improved on the speed of that library. I never liked the complexity and obstuseness of libXML so I looked around and ran across another XML library called miniXML (https://www.msweet.org/mxml/) which, to me, seemed easier to use.

 

I created a LabVIEW library wrapper for it and found that it's actually a little faster than Troy's updated libXML library. With the large file that's included, and on my system (i5-6600K), Troy's updated libXML library takes about 2.9 seconds to read the file, whereas miniXML takes about 1.9 seconds. Yes, not earth-shattering, but also not insignificant.

 

I'm providing it here in case anybody wants to try to use it as an alternative library or to see if it works faster for them. With small XML files you're unlikely to see any real difference - you'd likely need to use large files. I'm providing separate downloads.

 

The first download, "LabVIEW miniXML Library with Source.zip" (**) includes:

  • LabVIEW library itself.
  • The source code for miniXML - I used v3.3 of miniXML. There's a v3.3.1, though the changes for that version are only useful for POSIX systems.
  • A wrapper library that I had to write in order to be able to use some of the miniXML functions. The LabVIEW library will either call the miniXML DLL directly, or the wrapper libary, depending on the function.

(**) Due to the 10MB file size limitation I removed the auto-generated files that Visual Studio creates in the .vs folder. Thus, the first time you open the project it will be slow.

 

The second dowload, "LabVIEW miniXML Library no DLL source.zip" removes the C++ source code just to reduce the size. If you don't intend to be changing the source code, then you can just get this, which has the library and the pre-compiled DLLs. 

 

The third download, "LibXMLUpdate(2.1) with miniXML.zip" is TroyK's release with the example VI updated to allow using miniXML. Note that this download is independent, as the miniXML distribution is included in this download. So, if you want to try it out, get this download to test it out and if you decide to use it, you can get the library distribution download so you can incorporate it into your projects. 

Description-Separate-2

How to Use

How-Separate-1

The miniXML Programming Manual (https://www.msweet.org/mxml/mxml.html) provides details on all of the functions, which I've tried to replicate in the LabVIEW library.

 

Note that I was unable to replicate every single function, but I did get most of them either directly or via the wrapper DLL that I wrote.

 

You can take a look at my modified version of Troy's example to see how to parse the XML file provided in that example. 

 

Whether or not you think it's an alternative to libXML really comes down to what speed you need and whether you think it's got an easier to use API. The latter is subjective.

How-Separate-2

Additional Information

Additional-Separate-1

I used Visual Studio 2019 Community Edition, though it should be able to be used with 2022.

 

The source code provides the DLLs in 32-bit and 64-bit form. The distribution is linked to the 32-bit DLL. If you need the 64-bit version:

 

Copy the files from the miniXML\dll\64-bit folder to the miniXML\dll folder, replacing the two files that are there, which are the 32-bit versions.

 

To reduce the size of the distribution I deleted the compiler's object folders and bin outputs. I also deleted the pre-compiled header, which was huge. The first time you open the project in Visual Studio it might be slow since this .ipch file needs to be recreated.

 

Visual Studio has a convoluted folder naming scheme for targeting 32 and 64-bit C++ code. This doesn't happen with C# code, which is what I mostly use.

Additional-Separate-2

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors