<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thinking in G &#187; EasyXML</title>
	<atom:link href="http://thinkinging.com/category/easyxml/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkinging.com</link>
	<description>an unfiltered stream of data flow consciousness</description>
	<lastBuildDate>Fri, 02 Oct 2009 23:51:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating ordered elements in XML</title>
		<link>http://thinkinging.com/2008/05/20/creating-ordered-elements-in-xml/</link>
		<comments>http://thinkinging.com/2008/05/20/creating-ordered-elements-in-xml/#comments</comments>
		<pubDate>Tue, 20 May 2008 07:00:51 +0000</pubDate>
		<dc:creator>Jim Kring</dc:creator>
				<category><![CDATA[EasyXML]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://thinkinging.com/2008/05/13/creating-ordered-elements-in-xml/</guid>
		<description><![CDATA[




XML
doesn't inherently support element ordering. So, if you have XML that
looks like this (below), you can't&#160;deterministically say that
the element with
"foo" data comes before element with "bar" data.

&#60;element&#62;
&#160;&#160; &#60;data&#62;foo&#60;/data&#62;
&#60;/element&#62;
&#60;element&#62;
&#160;&#160; &#60;data&#62;bar&#60;/data&#62;
&#60;/element&#62;
&#60;element&#62;
&#160;&#160; &#60;data&#62;monkey&#60;/data&#62;
&#60;/element&#62;
&#60;element&#62;
&#160;&#160; &#60;data&#62;fish&#60;/data&#62;
&#60;/element&#62;

You can get around this XML limitation by explicitly adding an
order/index attribute to your ordered elements. For example:


&#60;element
n="1"&#62;
&#160;&#160; &#60;data&#62;foo&#60;/data&#62;
&#60;/element&#62;
&#60;element n="2"&#62;
&#160;&#160; &#60;data&#62;bar&#60;/data&#62;
&#60;/element&#62;
&#60;element n="3"&#62;
&#160;&#160; &#60;data&#62;monkey&#60;/data&#62;
&#60;/element&#62;
&#60;element n="4"&#62;
&#160;&#160; &#60;data&#62;fish&#60;/data&#62;
&#60;/element&#62;

In
order [...]]]></description>
			<content:encoded><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
XML
doesn't inherently support element ordering. So, if you have XML that
looks like this (below), you can't&nbsp;deterministically say that
the element with
"foo" data comes before element with "bar" data.<br />
<br />
<div style="font-family: monospace; margin-left: 40px;"
 class="codemain"><!--ec1-->&lt;element&gt;<br />
&nbsp;&nbsp; &lt;data&gt;foo&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element&gt;<br />
&nbsp;&nbsp; &lt;data&gt;bar&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element&gt;<br />
&nbsp;&nbsp; &lt;data&gt;monkey&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element&gt;<br />
&nbsp;&nbsp; &lt;data&gt;fish&lt;/data&gt;<br />
&lt;/element&gt;<!--c2--></div>
<!--ec2--><br />
You can get around this XML limitation by explicitly adding an
order/index attribute to your ordered elements. For example:<br />
<br />
<!--c1-->
<div style="font-family: monospace; margin-left: 40px;"
 class="codemain"><!--ec1-->&lt;element
n="1"&gt;<br />
&nbsp;&nbsp; &lt;data&gt;foo&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element n="2"&gt;<br />
&nbsp;&nbsp; &lt;data&gt;bar&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element n="3"&gt;<br />
&nbsp;&nbsp; &lt;data&gt;monkey&lt;/data&gt;<br />
&lt;/element&gt;<br />
&lt;element n="4"&gt;<br />
&nbsp;&nbsp; &lt;data&gt;fish&lt;/data&gt;<br />
&lt;/element&gt;<!--c2--></div>
<!--ec2--><br />
In
order to work with data like this, you'll need to pre-populate the "n"
attribute before you generate the XML (iterating over the elements and
setting the "n" attribute) and you'll need to post-process
the "n" attribute after you parse the XML (iterating over the elements
to get the "n" attribute and reordering the elements appropriately).<br />
<br />
Here's a LabVIEW example that
demonstrates this technique (note that this example uses JKI's <a
 href="http://jkisoft.com/easyxml/">EasyXML</a>
library):
<br />
<br />
<img id="image317"
 src="http://thinkinging.com/wp-content/uploads/2008/05/front%20panel.png"
 alt="front panel.png">
<br />
<br />
<img id="image318"
 src="http://thinkinging.com/wp-content/uploads/2008/05/block%20diagram.png"
 alt="block diagram.png">
<br />
<br />
For more tips and tricks for&nbsp;using XML in LabVIEW, and EasyXML
in particular, visit the <a
 href="http://forums.jkisoft.com/index.php?showforum=33">EasyXML
Tips and Tricks</a> page on the <a
 href="http://www.jkisoft.com/">JKI Software</a>
website.
<br />
<br />
</body>
</html>
]]></content:encoded>
			<wfw:commentRss>http://thinkinging.com/2008/05/20/creating-ordered-elements-in-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
