title: Adding an incrementing value attribute to every tag in xml using script
body: <p>I want to add an attribute to every tag in my xml, which is incrementing using either awk, sed, perl or plain shell cmd</p>
  
  <p>For Eg:</p>
  
  <pre><code>&lt;tag1 key="123"&gt;
    &lt;tag2 abc="xf d"/&gt;
    &lt;tag3 def="d2 32"&gt;
     &lt;/tag3&gt;
  &lt;/tag1&gt;
  </code></pre>
  
  <p>I am expecting the following output</p>
  
  <pre><code>&lt;tag1 key="123" order="1"&gt;
    &lt;tag2 abc="xf d" order="2"/&gt;
    &lt;tag3 def="d2 32" order="3"&gt;
     &lt;/tag3&gt;
  &lt;/tag1&gt;
  </code></pre>
  
  <p>If possible I am not looking on any dependencies(Twig,LibXML), pure string manipulation. </p>