title: DOMDocument::loadXML(): StartTag: invalid element name in Entity
body: <p>This is my xml:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;data&gt;
      &lt;client_name&gt;Awesome Client&lt;/client_name&gt;
      &lt;account_number/&gt;
      &lt;date_created&gt;02/12/2016&lt;/date_created&gt;
      &lt;form_number&gt;4126&lt;/form_number&gt;
      &lt;customer_po/&gt;
      &lt;terms_name&gt;Credit Card&lt;/terms_name&gt;
      &lt;date_shipped&gt;12/31/1969&lt;/date_shipped&gt;
      &lt;billing_contact_email/&gt;
      &lt;billing_contact_address_line_1/&gt;
      &lt;billing_contact_address_line_2/&gt;
      &lt;billing_contact_address_line_3/&gt;
      &lt;billing_contact_address_line_4/&gt;
      &lt;billing_contact_address_city/&gt;
      &lt;billing_contact_address_state&gt;British Columbia&lt;/billing_contact_address_state&gt;
      &lt;billing_contact_address_postal/&gt;
      &lt;billing_contact_address_country&gt;Canada&lt;/billing_contact_address_country&gt;
      &lt;shipping_contact_address_line_1/&gt;
      &lt;shipping_contact_address_line_2/&gt;
      &lt;shipping_contact_address_line_3/&gt;
      &lt;shipping_contact_address_line_4/&gt;
      &lt;shipping_contact_address_city/&gt;
      &lt;shipping_contact_address_state&gt;British Columbia&lt;/shipping_contact_address_state&gt;
      &lt;shipping_contact_address_postal/&gt;
      &lt;shipping_contact_address_country&gt;Canada&lt;/shipping_contact_address_country&gt;
      &lt;billing_contact_first_name&gt;another&lt;/billing_contact_first_name&gt;
      &lt;billing_contact_last_name&gt;client&lt;/billing_contact_last_name&gt;
      &lt;client_rep_full_name&gt;Rob Montebelli&lt;/client_rep_full_name&gt;
      &lt;order_rep_full_name&gt;Mark Graham&lt;/order_rep_full_name&gt;
      &lt;job_name&gt;77777&lt;/job_name&gt;
      &lt;job_number&gt;2620&lt;/job_number&gt;
      &lt;event_type&gt;Donor Gift&lt;/event_type&gt;
      &lt;due_date&gt;02/12/2016&lt;/due_date&gt;
      &lt;shipping_method/&gt;
      &lt;currency&gt;CAD&lt;/currency&gt;
      &lt;total_taxes&gt;0.00&lt;/total_taxes&gt;
      &lt;total_subtotal&gt;1,760.16&lt;/total_subtotal&gt;
      &lt;total&gt;1,760.16&lt;/total&gt;
      &lt;items&gt;
          &lt;item0&gt;
              &lt;taxes&gt;
                  &lt;0&gt;E&lt;/0&gt;
              &lt;/taxes&gt;
              &lt;title&gt;1889-24&lt;/title&gt;
              &lt;quantity&gt;6&lt;/quantity&gt;
              &lt;description&gt;Carhartt (R) Signature Utility Duffel; TBD TBD&lt;/description&gt;
              &lt;unit_price&gt;159.32&lt;/unit_price&gt;
          &lt;/item0&gt;
          &lt;item1&gt;
              &lt;taxes&gt;
                  &lt;0&gt;E&lt;/0&gt;
              &lt;/taxes&gt;
              &lt;title&gt;0022-56&lt;/title&gt;
              &lt;quantity&gt;12&lt;/quantity&gt;
              &lt;description&gt;Zoom (TM) DayTripper Sling Compu-Messenger; TBD TBD&lt;/description&gt;
              &lt;unit_price&gt;67.02&lt;/unit_price&gt;
          &lt;/item1&gt;
      &lt;/items&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>My code: </p>
  
  <pre><code>$xml_data = new SimpleXMLElement('&lt;?xml version="1.0"?&gt;&lt;data&gt;&lt;/data&gt;');
  array_to_xml($invoice, $xml_data);
  $xml = $xml_data-&gt;asXML();
  
  $domxml = new DOMDocument('1.0');
  $domxml-&gt;preserveWhiteSpace = false;
  $domxml-&gt;formatOutput = true;
  $domxml-&gt;loadXML($xml);
  $xml_string = $domxml-&gt;saveXML();
  </code></pre>
  
  <p>I think the xml is in the right format so why is this failing? </p>
  
  <p>Edit:</p>
  
  <p>Here is the dynamic array before converted into xml using XMLSimpleElement, is there anyway to remove &lt;0> before converted into xml?:</p>
  
  <pre><code>Array
  (
      [invoices] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [client_name] =&gt; Awesome Client
                      [account_number] =&gt; 
                      [date_created] =&gt; 02/11/2016
                      [form_number] =&gt; 4104
                      [customer_po] =&gt; 
                      [terms_name] =&gt; Credit Card
                      [date_shipped] =&gt; 12/31/1969
                      [billing_contact_email] =&gt; 
                      [billing_contact_address_line_1] =&gt; 
                      [billing_contact_address_line_2] =&gt; 
                      [billing_contact_address_line_3] =&gt; 
                      [billing_contact_address_line_4] =&gt; 
                      [billing_contact_address_city] =&gt; 
                      [billing_contact_address_state] =&gt; British Columbia
                      [billing_contact_address_postal] =&gt; 
                      [billing_contact_address_country] =&gt; Canada
                      [shipping_contact_address_line_1] =&gt; 
                      [shipping_contact_address_line_2] =&gt; 
                      [shipping_contact_address_line_3] =&gt; 
                      [shipping_contact_address_line_4] =&gt; 
                      [shipping_contact_address_city] =&gt; 
                      [shipping_contact_address_state] =&gt; British Columbia
                      [shipping_contact_address_postal] =&gt; 
                      [shipping_contact_address_country] =&gt; Canada
                      [billing_contact_first_name] =&gt; another
                      [billing_contact_last_name] =&gt; client
                      [client_rep_full_name] =&gt; Rob Montebelli
                      [order_rep_full_name] =&gt; Mark Graham
                      [job_name] =&gt; 5010
                      [job_number] =&gt; 2598
                      [event_type] =&gt; Donor Gift
                      [due_date] =&gt; 02/11/2016
                      [shipping_method] =&gt; 
                      [currency] =&gt; CAD
                      [total_taxes] =&gt; 0.00
                      [total_subtotal] =&gt; 1,760.16
                      [total] =&gt; 1,760.16
                      [items] =&gt; Array
                          (
                              [0] =&gt; Array
                                  (
                                      [taxes] =&gt; Array
                                          (
                                              [0] =&gt; E
                                          )
  
                                      [title] =&gt; 1889-24
                                      [quantity] =&gt; 6
                                      [description] =&gt; Carhartt (R) Signature Utility Duffel; TBD TBD
                                      [unit_price] =&gt; 159.32
                                  )
  
                              [1] =&gt; Array
                                  (
                                      [taxes] =&gt; Array
                                          (
                                              [0] =&gt; E
                                          )
  
                                      [title] =&gt; 0022-56
                                      [quantity] =&gt; 12
                                      [description] =&gt; Zoom (TM) DayTripper Sling Compu-Messenger; TBD TBD
                                      [unit_price] =&gt; 67.02
                                  )
  
                          )
  
                  )
  
          )
  
  )
  </code></pre>