Jump to content

Help xml atributes


Xrockyman

Recommended Posts

Dear users,

 

I'm new to XML and easyXML appears to be an easy solution for the problem I have. What I want to do is easier to understand if we look at the image that I have uploaded :) My objective is to generate a XML file similar to the "string constant" below and I'm not able to atribute the vector index in "value" field. What do I need to do more to have similar xml output?

 

Sorry if I have not explained correctly:)

Thanks in advance.

 

Regards,

Xrockyman

Link to comment
Share on other sites

Thanks for (re)posting your example.

 

There are a couple things that should be mentioned:

 

1) How to handle attributes using EasyXML - please take a look at the Generating and Parsing Scalar XML Elements with Attributes article to see examples of some of the variations of how attributes can be handled in EasyXML.

 

2) How to create ordered elements in EasyXML - when an attribute (such as "xid", in your example) is used as an index, you can do some tricks to ensure that the items are ordered correctly in the LabVIEW array. See the Creating ordered elements in XML article for more details about this technique.

 

Please let me know if these links (especially the Creating ordered elements in XML article) provide you with enough information to program your application or if you have an other questions.

 

Thanks,

 

-Jim

Link to comment
Share on other sites

Thanks for (re)posting your example.

 

There are a couple things that should be mentioned:

 

1) How to handle attributes using EasyXML - please take a look at the Generating and Parsing Scalar XML Elements with Attributes article to see examples of some of the variations of how attributes can be handled in EasyXML.

 

2) How to create ordered elements in EasyXML - when an attribute (such as "xid", in your example) is used as an index, you can do some tricks to ensure that the items are ordered correctly in the LabVIEW array. See the Creating ordered elements in XML article for more details about this technique.

 

Please let me know if these links (especially the Creating ordered elements in XML article) provide you with enough information to program your application or if you have an other questions.

 

Thanks,

 

-Jim

 

Thanks for your quick answer. I almost have what I need but I have a doubt, in the example "Creating ordered elements in XML", in the elment that I want to order always appears "unnamed cluster" and not the label that I gave. And this happens also in your example, it shows :

<unnamed_cluster n="1">

<data>foo</data>

</unnamed_cluster>

 

and should appear:

 

<element n="1">

<data>foo</data>

</element>

 

Thanks in advance and sorry if this is this question to simple.

 

Regards,

Xrockyman.

Link to comment
Share on other sites

Thanks for your quick answer. I almost have what I need but I have a doubt, in the example "Creating ordered elements in XML", in the elment that I want to order always appears "unnamed cluster" and not the label that I gave. And this happens also in your example, it shows :

foo

 

and should appear:

 

foo

 

Thanks in advance and sorry if this is this question to simple.

 

Regards,

Xrockyman.

 

I don't think that I see the same thing as you. For example, when I run the "Creating ordered elements in XML", I get:

 

foo

 

Can you please post a simple example VI that demonstrates your problem? This would help me understand what you are seeing and hopefully fix any problems.

 

Thanks,

Link to comment
Share on other sites

I don't think that I see the same thing as you. For example, when I run the "Creating ordered elements in XML", I get:

 

<element n="1">

<data>foo</data>

</element>

 

Can you please post a simple example VI that demonstrates your problem? This would help me understand what you are seeing and hopefully fix any problems.

 

Thanks,

 

Here is screen shot. I did not modify anithing in the code, I'm running Labview 8.5, could this be a problem?

 

Thanks,

Xrockyman

post-2532-1221664192_thumb.jpg

Link to comment
Share on other sites

Yes, the problem is that in LabVIEW 8.5 (and in 8.6, but I haven't tested 8.0 or 8.2) LabVIEW loses the array name at the For Loop. This can be fixed by adding a Variant to Data function after the For Loop to reset the array name to the one it had upstream of the For Loop. See the screenshot, below, for the fix.

 

1.png

 

Thanks for your patience on this -- I was testing in LabVIEW 7.1, so I wasn't seeing the change in LabVIEW behavior :)

 

I'll re-upload a fix for the example in the "Creating ordered elements in XML" article.

Link to comment
Share on other sites

  • 2 weeks later...

Hello, I have another doubt, in my previous post (Sep 17 2008, 04:19 PM) I had the problem of the "unamed cluster". To solve that in my Labview 8.5, you told me to use the function variant to data to retrieve the lost labels in loop burt what I want is to retrieve only the name of the cluster and not the names of his elements. What I want is this:

<value xid="0">1949</value>

<value xid="1">1950</value>

<value xid="2">1951</value>

 

and the only thing that I can get is this:

 

<value xid="1">

<unnamed_numeric>1949</unnamed_numeric>

</value>

<value xid="2">

<unnamed_numeric>1950</unnamed_numeric>

</value>

<value xid="3">

<unnamed_numeric>1951</unnamed_numeric>

</value>

<value xid="4">

<unnamed_numeric>1952</unnamed_numeric>

</value>

 

I want the "<unnamed_numeric>" to go away to stay only the value.

 

Thanks in advance and best regards,

Sylvain

take3256.vi

Link to comment
Share on other sites

What I want is this:

1949

1950

1951

 

and the only thing that I can get is this:

 

1949

1950

1951

1952

 

This is slightly tricky...

 

The solution is to use the same name (label) for the numeric as you do for the array:

 

1.png

 

Here is your example, fixed:

 

take3256__fixed.vi

 

By the way, this is covered in the Generating and Parsing Scalar XML Elements with Attributes article, under the List of Scalar Elements with Attributes section.

 

Let me know if this makes sense and if you have any more questions.

 

Thanks,

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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