LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing a non-standard (LabVIEW) xml file

Highlighted

I inherited an xml file which does not use the normal LabVIEW schema, where the types would be defined for each value and the number of elements would be defined for an array.  Although a schema file xsl is listed in the xml header, no such file exists.

 

Below is a example of the file's contents.  It is a much much shorter version of the actual file.  As I look at the file and start to implement code to support it, I am wondering if I am creating an oversized monster better known as Rube Goldberg code for this task.  Below is the snippet for the latest attempt that I started (obviously unfinished).   It is obvious that I am not an expert at dealing with xml files, which is why I posted this thread.  In other words, I am seeking advice on the appropriate approach to extract values from an exl file that contains code similar to that below.

 

The LabVIEW code will need to do 2 things:  

 

1. parse the file and populate clusters with the data (I am trying to avoid a giant cluster)

 

2. allow to edit the values and write them back to the xml file, while retaining the original format (this is where it becomes tricky).

 

I have tried a couple of other approaches that I was not happy with.  Below is the snippet for the latest code that I just started.  I'm trying to avoid falling into the rabbit hole.

 

 

 

 

 

 

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>

<?xml-stylesheet type="text/xsl" href="myschema.xsl"?>

<calibration>

  <header>

    <hash>bogus123</hash>

    <version>15</version>

    <date>Dec-2-2014</date>

    <author>Me</author>

    <description>Calibration data.</description>

    <comments>new auto-generation</comments>

<unit-serial-number>007</unit-serial-number>

<unit-assembly-number>A01.00</unit-assembly-number>

<base-serial-number>533</base-serial-number>

<module-serial-number>788</module-serial-number>

<di-serial-number>001</di-serial-number>

<di-assy-number>123-01</di-assy-number>

  </header>

  <content>

    <data>

      <name>Power</name>

      <description>Output power vs Frequency</description>

      <params>

        <param name="RFFlag">TRUE</param>

         <param name="Temperature">38</param>

        <param name="BaudRate">115200</param>

      </params>

      <table>

        <params>

          <param name="Frequency">5551212</param>

        </params>

        <header>Pout (dBm), RF_GAIN</header>

        <rows>

<row>0,0x05</row>

<row>0.5,0x08</row>

<row>1,0x0A</row>

<row>1.5,0x0C</row>

<row>2,0x1F</row>

<row>2.5,0x12</row>

<row>3,0x16</row>

<row>3.5,0x1A</row>

<row>4,0x1E</row>

<row>4.5,0x23</row>

<row>5,0x28</row>

<row>5.5,0x2D</row>

        </rows>

      </table>

      <table>

        <params>

          <param name="Frequency">9993333</param>

        </params>

        <header>Pout (dBm), RF_GAIN</header>

        <rows>

<row>0,0x05</row>

<row>0.5,0x08</row>

<row>1,0x0A</row>

<row>1.5,0x0C</row>

<row>2,0x1F</row>

<row>2.5,0x12</row>

<row>3,0x16</row>

<row>3.5,0x1A</row>

<row>4,0x1E</row>

<row>4.5,0x23</row>

<row>5,0x28</row>

<row>5.5,0x2D</row>

        </rows>

      </table>

    </data>

    <data>

      <name>Loss</name>

      <description>loss vs frequency</description>

      <params>

        <param name="Temperature">34</param>

      </params>

      <table>

        <header>Frequency, Loss</header>

        <rows>

          <row>5551212,0.8</row>

          <row>6661313,0.8</row>

          <row>7771414,0.8</row>

        </rows>

      </table>

    </data>

      <name>Attenuation</name>

      <description>RF vs attenuation</description>

      <table>

        <header>index, DAC</header>

        <rows>

          <row>1,  0xCCC</row>

          <row>2,  0xCCC</row>

          <row>3,  0xCCC</row>

          <row>4,  0xCCC</row>

          <row>5,  0xCCC</row>

          <row>6,  0xCCC</row>

          <row>7,  0xCCC</row>

        </rows>

      </table>

    </data>

    <data>

      <name>Current</name>

      <description>current vs Pout</description>

      <table>

        <header>ADC, current</header>

        <rows>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x2,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

          <row>0x3,  0x66</row>

        </rows>

      </table>

    </data>

   </content>

</calibration>

______________________________________________________________________
0 Kudos
Message 1 of 5
(1,250 Views)
Highlighted

Step away from the mouse.  Google 'XPath'.  Learn it.  Then try again using 'Find Matching Nodes'.  You'll thank me, it is not that hard and quite powerful.

Message 2 of 5
(1,238 Views)
Highlighted

Hi Darin.

 

How have you been?  Wishing you a belated Happy New Year!

 

I like your expression:  "step away from the mouse".  Very much to the point.  

 

Thanks for the advice.  I'll check out XPath.

 

Cheers,


RayR

______________________________________________________________________
0 Kudos
Message 3 of 5
(1,226 Views)
Highlighted

I think you are missing an extra "data" in here:

    </data>

      <name>Attenuation</name>

 

Would populating a tree be easier than a cluster?

If you do go the cluster route, you'll want to use some of the variant probing tools in vi lib. That way you can follow your cluster and populate it programmatically.

 

0 Kudos
Message 4 of 5
(1,213 Views)
Highlighted

@Ray.R wrote:

Hi Darin.

 

How have you been?  Wishing you a belated Happy New Year!

 

I like your expression:  "step away from the mouse".  Very much to the point.  

 

Thanks for the advice.  I'll check out XPath.

 

Cheers,


RayR


Doing well, Thanks.  Wishing you an early Chinese New Year.  (that's going to get bleeped). [Edit:  Yay, no more bleeping Chinese]

 

Be a little careful with XPath.  Some people have been known to wrap C++ libraries to have access to XPath 2.0 and an XSLT engine for awesome search and replace capabilities.  Others have been known to find ways to program XPath graphically:

 

XPathLibrary.png

0 Kudos
Message 5 of 5
(1,199 Views)