title: How do I omit the xml version tag when a xml file is created in php
body: <p>I've made this program that updates an xml file based on entries in an array.
  I've used FILE_APPEND because the entries are more than one and otherwise file gets overwritten. But the problem is the xml version tag prints out as many times as many entries are there.
  So i want to remove this tag.
  Here's my program:-</p>
  
  <pre><code>    &lt;?php
      include 'array.php';
  
      $xmlW = new XMLWriter();
      $file = 'entry-'. date('M-D-Y') .'.xml';
  
      /*$setting = new XMLWriterSettings();
      $setting-&gt;OmitXmlDeclaration = true;*/
  
  
      foreach($data as $d) {
  
          if(in_array ($d['Mode'], array('ccAV','MB','Paypal','E2P'))) {
          $recordType = 'receipt';
          $xml_object = simplexml_load_file ('receipt.xml');
      } else {
          $xml_object = simplexml_load_file ('journal.xml');
          $recordType = 'journal';
      }
  
  
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER")[0]-&gt;DATE = $d['InvoiceDate'];
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER")[0]-&gt;NARRATION = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER")[0]-&gt;EFFECTIVEDATE = $d['InvoiceDate'];
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST")[0]-&gt;LEDGERNAME = $d['Mode'];
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST")[0]-&gt;AMOUNT = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST")[1]-&gt;AMOUNT = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST")[2]-&gt;AMOUNT = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST/BANKALLOCATIONS.LIST")[0]-&gt;DATE = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST/BANKALLOCATIONS.LIST")[0]-&gt;INSTRUMENTDATE = 'Rahul';
      $xml_object-&gt;xpath("/ENVELOPE/BODY/IMPORTDATA/REQUESTDATA/TALLYMESSAGE/VOUCHER/ALLLEDGERENTRIES.LIST/BANKALLOCATIONS.LIST")[0]-&gt;AMOUNT = 'Rahul';
  
      $xml = $xml_object-&gt;asXML();
  
      file_put_contents($file, $xml, FILE_APPEND);
      }
      ?&gt;
  </code></pre>
  
  <p>Thanks for the help.</p>