Jump to content
amaggs145

Print Array Index numbers in XML string

Recommended Posts

We are using XML data format to store data that is being used on both a Linux machine and a Windows machine. On the Linux side the XML file is generated using Perl. One of the data types that are being written to the XML file is a hash, the hash is written to the file quite nicely and I would like to be able to write the data in the same way using Easy XML Toolkit.

 

The data that is being written is just an array of 1's and 0's, so its really Boolean data in LabVIEW but because we want to see actual 1's and 0's I can just convert my Boolean array to 1's and 0's before writing.

 

So I have this array of 1's and 0's, and if I use the Easy XML Toolkit to write it, I get something like the following:

 

<REGPGMS>

<name>R0</name>

<bit>0</bit>

<bit>1</bit>

<bit>1</bit>

<bit>1</bit>

<bit>0</bit>

<bit>1</bit>

<bit>0</bit>

<bit>1</bit>

</REGPGMS>

 

I lose the array index information. However, however my colleague has his data set up in Perl he has the ability to produce the following:

 

<REGPGMS>

<name>R0</name>

<bit00>0</bit00>

<bit01>1</bit01>

<bit02>1</bit02>

<bit03>1</bit03>

<bit04>0</bit04>

<bit05>1</bit05>

<bit06>0</bit06>

<bit07>1</bit07>

</REGPGMS>

 

what is the way to this with the Easy XML Toolkit?

 

I did read the Compound Elements with Attributes section in the Tips & Tricks, but it doesn't seem I would be able to produce exactly what the Perl code is producing with the use of attributes.

 

One way to do this is to have a cluster that has the same number of U8 integers as the number of bits I want to print, and name each integer control with the appropiate "bitXX" syntax. But I really don't want to have to deal with custom controls here, as the number of bits in an array could change.

 

Thanks so much for any help http://forums.jki.net/public/style_emoticons/default/wink.gif

Edited by amaggs145

Share this post


Link to post
Share on other sites

Hi,

 

Are you married to the schema designed by your colleague in Pearl?

 

IMO, it's pretty difficult to deal with, in the case where you want scalability of the number of bits. For example, it would be hard to validate it using a XSD or DTD.One solution might be to use attributes, like this:

 

<REGPGMS>
<name>R0</name>
<bit i="0">0</bit>
<bit i="1">1</bit>
<bit i="2">1</bit>
<bit i="3">1</bit>
<bit i="4">0</bit>
<bit i="5">1</bit>
<bit i="6">0</bit>
<bit i="7">1</bit>
</REGPGMS>

 

Thanks,

 

-Jim

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.