Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is node order important in XML?
    primarykey
    data
    text
    <p>I've been dealing with an API recently that requires nodes of the XML document to be in a particular order. I was wondering why they feel the need to enforce this when I can find absolutely no reason why things should be like this.</p> <p>For intance, this would be correct (xml greatly simplified)</p> <pre><code>&lt;transaction&gt; &lt;address&gt;1 main st&lt;/address&gt; &lt;amount&gt;100&lt;/amount&gt; &lt;orderId&gt;1234&lt;/orderId&gt; &lt;/transaction&gt; </code></pre> <p>but this would return an error</p> <pre><code>&lt;transaction&gt; &lt;address&gt;1 main st&lt;/address&gt; &lt;orderId&gt;1234&lt;/orderId&gt; &lt;amount&gt;100&lt;/amount&gt; &lt;/transaction&gt; </code></pre> <p>At first I thought it would be so that they can store things in a list/array form and have the indices always refer to the same node. I understand why sending sibling nodes that have the same name in the same order is important as explained <a href="https://stackoverflow.com/questions/1131495/in-xml-is-order-important">in this question</a>. However, some nodes can be left out:</p> <pre><code>&lt;transaction&gt; &lt;amount&gt;100&lt;/amount&gt; &lt;orderId&gt;1234&lt;/orderId&gt; &lt;/transaction&gt; </code></pre> <p>So in the third example, amount and orderId would now be at [0] and [1] instead of at [1] and [2] in the first (correct) example.</p> <p>Another thought would be that they process the XML as a string and require that they always know what nodes come after each other, but again since omitting nodes is allowed, that theory doesn't make sense.</p> <p>Can anyone explain to me why the order in which I give nodes matters? Or am I just dealing with an API that is old and grumpy?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload