title: PHP SimpleXML: insert node at certain position
body: <p>say I have XML:</p>
  
  <pre><code>&lt;root&gt;
    &lt;nodeA /&gt;
    &lt;nodeA /&gt;
    &lt;nodeA /&gt;
    &lt;nodeC /&gt;
    &lt;nodeC /&gt;
    &lt;nodeC /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>How do I insert "nodeB" between As and Cs? In PHP, preferably via SimpleXML? Like:</p>
  
  <pre><code>&lt;root&gt;
    &lt;nodeA /&gt;
    &lt;nodeA /&gt;
    &lt;nodeA /&gt;
    &lt;nodeB /&gt;
    &lt;nodeC /&gt;
    &lt;nodeC /&gt;
    &lt;nodeC /&gt;
  &lt;/root&gt;
  </code></pre>