title: SimpleXml how to correctly set encoding and xmins?
body: <p>Any ideas on how I can get PHPs SimplXMLElement to kick off with the following?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;kml xmlns="http://earth.google.com/kml/2.2"&gt;
  </code></pre>
  
  <p>The main root will then be:</p>
  
  <pre><code>&lt;Document&gt;&lt;/Document&gt;
  </code></pre>
  
  <p>Or do I use simplexml_load_string() to set it up?</p>
  
  <p>Context: I am extending simpleXmlElement to create some kml files.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Actually, setting the kml xmlns was laughably easy to do:</p>
  
  <pre><code>new simpleXMLElement('&lt;kml xmlns="http://earth.google.com/kml/2.2"&gt;
  &lt;Document&gt;&lt;/Document&gt;&lt;/kml&gt;');
  </code></pre>
  
  <p>Just how to set encoding="UTF-8" that is bothering me, seemingly the kml is acceptable without that, but I'd still like to understand how to do it if pos.</p>