title: Nesting simplexml
body: <p>Try to wright a xml with SimpleXmL. Need to nest some of the tags</p>
  
  <pre><code> $xml = new SimpleXMLElement('&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;orders&gt;&lt;/orders&gt;');
          $orderlist = $xml-&gt;addChild('order');
          $orderlist-&gt;addAttribute('shipdate', date('Y-m-d H:i:s'));
  
          $orderlist = $xml-&gt;addChild('delivery');
          $orderlist-&gt;addAttribute('weight', '0');
  </code></pre>
  
  <p>This will output this:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;orders&gt;
          &lt;order shipdate="2017-10-11 13:44:12" /&gt;
          &lt;delivery weight="0" /&gt;
      &lt;order/&gt;
      &lt;/orders&gt;
  </code></pre>
  
  <p>But need the  tag not to close before the  tag. 
  Want it to look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;orders&gt;
    &lt;order shipdate="2016-07-14T14:41:30"&gt;
      &lt;delivery weight="0" /&gt;
    &lt;/order&gt;
  &lt;/orders&gt;
  </code></pre>