Showing results for 
Search instead for 
Did you mean: 

Convert Data to xml string without ordering attributes alphabetically

Hello everyone,


I'm trying to generate a xml string using Labview data/constants and I'm facing the problem that the "Set attribute method" sorts the attributes declared/appended in alphabetical order.


For the type of server that I'm trying to send this xml, the attributes order matters and this is a problem for me. I need to have the attributes on the appended order.


Does anyone have a suggestion or knowledge about how to avoid this factor and display attributes on a xml file in the appended order?


Thank you  


0 Kudos
Message 1 of 3

According to the XML specification, the order of attributes is not significant:


If the order is important to you, you should use element nodes instead of attributes, which would give you this:



If however you really need them to be attributes, I guess you could write your own XML generator, but it would be a lot of work and the format wouldn't be standard XML anymore...


0 Kudos
Message 2 of 3

I've done a little XML in LabVIEW (mostly about 10 years ago), exploring native LabVIEW XML, JKI's "Easy XML" (LabVIEW Tools Network), and GXML (also on LabVIEW Tools Network).  I ended up using GXML, but only after I wrote a few "extensions" to it that might have deviated slightly from the XML "standards", but made it much easier for me to create "Typed" documents (data from complex LabVIEW Data Acquisition routines) that supported "write as you go" as opposed to "write everything all at once".


What is to stop you, if you want the Attributes to be listed in a particular order (and you know the Attributes that are present, and the order you want them in), from reading the XML file, extracting lists of consecutive Attributes, re-ordering them in whatever way you want, and replacing them in "User-defined ordering" (as opposed to "Alphabetic"?  Why wouldn't this be just as valid an XML document?  It is certainly easy enough to try it out (you don't even need to use LabVIEW -- take an "Alphabetized Attribute" XML File, open it in a good Text Editor, find the Attribute section, re-order it, and see what happens when you "use" the revised document.  If it works, it is easy enough to write the LabVIEW "Order Attributes My Way" routine as an XML "Post-Processor"


Bob Schor

0 Kudos
Message 3 of 3