title: Getting encoding="UTF-8" standalone="yes" using PHP asXML and SimpleXMLElement
body: <p>I am using following code to get an XML file when a php page is called:</p>
  
  <p>i.e. when you enter <code>http://example.com/strtoxmp.php</code>, it will return you <strong>xml</strong>,  based on following coding:</p>
  
  <pre><code>  $xml = new SimpleXMLElement("&lt;feed/&gt;");
  
    $feed = $xml;
    $feed-&gt;addChild('resultLength', "1");
    $feed-&gt;addChild('endIndex', "1");
  
    $item = $feed-&gt;addChild('item',"");
    $item-&gt;addChild('contentId', "10031");
    $item-&gt;addChild('contentType', "Talk");
    $item-&gt;addChild('synopsis', "$newTitle" );
    $item-&gt;addChild('runtime', ' ');
  }
  
  Header('Content-type: text/xml;  charset:UTF-8; ');
  
  print($xml-&gt;asXML());
  </code></pre>
  
  <p>and it is working fine. It produces following xml:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;feed&gt;
  &lt;resultLength&gt;1&lt;/resultLength&gt;
  &lt;endIndex&gt;1&lt;/endIndex&gt;
  &lt;contentId&gt;10031&lt;/contentId&gt;
  &lt;contentType&gt;Talk&lt;/contentType&gt;
  &lt;synopsis&gt;Mark Harris - Find Your Wings&lt;/synopsis&gt;
  &lt;runtime&gt; &lt;/runtime&gt;
  &lt;/item&gt;
  &lt;/feed&gt;
  </code></pre>
  
  <p>But I need</p>
  
  <blockquote>
    <p>&lt; ?xml version="1.0" encoding="UTF-8" standalone="yes"?></p>
  </blockquote>
  
  <p>instead of </p>
  
  <blockquote>
    <p>&lt; ?xml version="1.0"?></p>
  </blockquote>