Xrockyman Posted September 16, 2008 Report Share Posted September 16, 2008 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 More sharing options...
Jim Kring Posted September 16, 2008 Report Share Posted September 16, 2008 Xrockyman, I don't see any attachment to your post. Can you retry posting your example and/or screenshot? Thanks, -Jim Link to comment Share on other sites More sharing options...
Xrockyman Posted September 17, 2008 Author Report Share Posted September 17, 2008 Xrockyman, I don't see any attachment to your post. Can you retry posting your example and/or screenshot? Thanks, -Jim Hello, I'm sorry I probably forgot to click on the "upload" button for the attachment. Here It goes. Thanks, Xrockyman. Link to comment Share on other sites More sharing options...
Jim Kring Posted September 17, 2008 Report Share Posted September 17, 2008 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 More sharing options...
Xrockyman Posted September 17, 2008 Author Report Share Posted September 17, 2008 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 More sharing options...
Jim Kring Posted September 17, 2008 Report Share Posted September 17, 2008 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 More sharing options...
Xrockyman Posted September 17, 2008 Author Report Share Posted September 17, 2008 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 Link to comment Share on other sites More sharing options...
Xrockyman Posted September 17, 2008 Author Report Share Posted September 17, 2008 And here is the version of my code, this approximate of what I want to do and where is marked red I want the "value". Thanks, Xrockman mycode.vi Link to comment Share on other sites More sharing options...
Jim Kring Posted September 17, 2008 Report Share Posted September 17, 2008 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. 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 More sharing options...
Xrockyman Posted September 17, 2008 Author Report Share Posted September 17, 2008 Thanks for your "ultra-fast" answer! now problem is fully solved. Regards, Xrockyman. Link to comment Share on other sites More sharing options...
Jim Kring Posted September 17, 2008 Report Share Posted September 17, 2008 Thanks for your "ultra-fast" answer! now problem is fully solved.Regards, Xrockyman. You're very welcome. Please let us know if you have any other questions about how to use EasyXML in programming your application. Link to comment Share on other sites More sharing options...
Xrockyman Posted September 25, 2008 Author Report Share Posted September 25, 2008 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 More sharing options...
Jim Kring Posted September 26, 2008 Report Share Posted September 26, 2008 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: 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 More sharing options...
Xrockyman Posted September 26, 2008 Author Report Share Posted September 26, 2008 Thanks for you fast reply, now I can construct my XML just like I want. Best regards:) Sylvain Link to comment Share on other sites More sharing options...
Jim Kring Posted September 26, 2008 Report Share Posted September 26, 2008 Thanks for you fast reply, now I can construct my XML just like I want.Best regards:) Sylvain Hi Sylvain, That's great news! Let us know if you have any other issues or questions. Thanks, -Jim Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.