JKI Discussion Forums
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

XML Representation

#1
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09
Hello,
I have a data format that I'm having trouble representing in LabVIEW as a format that the EasyXML tool can translate. I think it's impossible, but I wanted to make sure before I gave up. Essentially, an array of data has to be represented in a format where each array value is represented as an attribute of a RAW tag. Please see the attached files. Thanks in advance for your help.

Attached thumbnail(s)

  • Attached Image: xmltest.jpg

Attached File(s)


0 kudos

#2
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06
Hi Matt,

Here's the solution, below.

Note that your XML was not valid, as there must be only one root-level element. To fix this, I wrapped "MeasurementX" and "MeasurementY" in an element named "Root" (<Root></Root>).

Attached File  MeasurementExample.vi (15.09K)
Number of downloads: 62

Attached Image: 1.png

Please let me know if you have any more questions. I'm happy to help. Also, there's some detailed documentation located, here, although sometimes it's a little tricky to see how every XML structure maps into EasyXML's LabVIEW structures.

-Jim
0 kudos

#3
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09
Jim,

When I just reverse the code you sent to just create an xml string, the result is incorrect.

Attached File(s)


0 kudos

#4
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06

View PostMatt C, on Mar 9 2009, 07:34 AM, said:

Jim,

When I just reverse the code you sent to just create an xml string, the result is incorrect.


Hi Matt,

I'm not sure what you are seeing that makes you think that the result is not correct. When I run the example you sent me, with data populated in the arrays, I get:

Quote

<Root>
<MeasurementX>
<RAW VALUE="0.02"/>
<RAW VALUE="0.03"/>
<RAW VALUE="0.04"/>
<RAW VALUE="0.05"/>
</MeasurementX>
<MeasurementY>
<RAW VALUE="0.5"/>
<RAW VALUE="0.6"/>
<RAW VALUE="0.7"/>
<RAW VALUE="0.8"/>
</MeasurementY>
</Root>


Attached File  MeasurementExample_Reversed_JK01.vi (10.86K)
Number of downloads: 57

Attached Image: MeasurementExample_Reversed_JK01.png

In order for me to be able help better, can you tell me what are you seeing vs. what you expected to see?

Thanks,

-Jim
0 kudos

#5
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09
Jim,

The trouble is with the RAW tags. The output format should be

<MeasureX>
<RAW VALUE="0.02">
</RAW>
<RAW VALUE="2.1000000000000001E-2">
</RAW>
</MeasureX>

but comes out as

<MeasureX>
<RAW VALUE="1"/>
<RAW VALUE="2"/>
</MeasureX>
0 kudos

#6
User is offline   Omar Mussa 

  • Group: JKI Team
  • Posts: 88
  • Joined: 12-October 06

View PostMatt C, on Mar 9 2009, 04:17 PM, said:

The trouble is with the RAW tags. The output format should be

<MeasureX>
<RAW VALUE="0.02">
</RAW>
<RAW VALUE="2.1000000000000001E-2">
</RAW>
</MeasureX>

but comes out as

<MeasureX>
<RAW VALUE="1"/>
<RAW VALUE="2"/>
</MeasureX>


The two XML structures are equivalent for empty content data (which can support attributes). Here is a link on Wikipedia:
http://en.wikipedia.org/wiki/XML

Search for the following text:

Quote

XML provides special syntax for representing an element with empty content. Instead of writing a start-tag followed immediately by an end-tag, a document may contain an empty-element tag. An empty-element tag resembles a start-tag but contains a slash just before the closing angle bracket. The following three examples are equivalent in XML:


I know there are more formal references for XML but in this case the Wikipedia page is much easier to read and understand.

Omar
0 kudos

#7
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06

View PostMatt C, on Mar 9 2009, 08:17 AM, said:

Jim,

The trouble is with the RAW tags. The output format should be

<MeasureX>
<RAW VALUE="0.02">
</RAW>
<RAW VALUE="2.1000000000000001E-2">
</RAW>
</MeasureX>

but comes out as

<MeasureX>
<RAW VALUE="1"/>
<RAW VALUE="2"/>
</MeasureX>



Hi Matt,

Are you concerned about the difference between the empty elements "<RAW></Raw>" and "<RAW/>" or the difference in the numeric precision of the "VALUE" attributes?

Thanks,

-Jim
0 kudos

#8
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09

View PostJim Kring, on Mar 9 2009, 01:43 PM, said:

Hi Matt,

Are you concerned about the difference between the empty elements "<RAW></Raw>" and "<RAW/>" or the difference in the numeric precision of the "VALUE" attributes?

Thanks,

-Jim



Jim, I was looking at the "<RAW></Raw>" and "<RAW/>" difference. But assuming that they are equivalent when parsed by a DOM parser, I guess that this isn't really an issue then. Thanks for the help Jim and Omar.
0 kudos

#9
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06

View PostMatt C, on Mar 9 2009, 12:01 PM, said:

Jim, I was looking at the "<RAW></Raw>" and "<RAW/>" difference. But assuming that they are equivalent when parsed by a DOM parser, I guess that this isn't really an issue then. Thanks for the help Jim and Omar.


Yes, "<RAW></Raw>" and "<RAW/>" are equivalent. DOM parsers and EasyXML should have no trouble with either format.
0 kudos

#10
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09
I've just run into another potential problem. My xml structure has attributes which have colon's (:) in the name. The rest of the items in my cluster load fine, but those with the colon do not load. Unfortunately, I don't define the xml structure so I have to just try to make it work. Help please!

This post has been edited by Matt C: 11 March 2009 - 08:50 PM

0 kudos

#11
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06

View PostMatt C, on Mar 11 2009, 12:49 PM, said:

I've just run into another potential problem. My xml structure has attributes which have colon's (:) in the name. The rest of the items in my cluster load fine, but those with the colon do not load. Unfortunately, I don't define the xml structure so I have to just try to make it work. Help please!


Hi Matt,

We've fixed this issue. I'll send you an email with details.

Thanks,

-Jim
0 kudos

#12
User is offline   Matt C 

  • Group: Members
  • Posts: 6
  • Joined: 05-March 09
Works great Jim! Thanks :)
0 kudos

#13
User is offline   Jim Kring 

  • Group: JKI Team
  • Posts: 1,204
  • Joined: 15-March 06

View PostMatt C, on Mar 12 2009, 08:39 AM, said:

Works great Jim! Thanks :)


You're welcome, Matt. Let us know if you find any other limitations or if you think of ways that we can make EasyXML better (or easier).

Cheers,

-Jim
0 kudos

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic