title: How do I create an empty/blank SimpleXMLElement in PHP?
body: <p>I am trying to use a PHP document to construct an XML document (for AJAX) using PHP 5's built-in <code>SimpleXMLElement</code> class. I want to start with a blank slate and build the XML element by element, but I have found no way to construct a <code>SimpleXMLElement</code> without starting from some existing piece of XML code. I wasn't able to successfully pass in a blank string ("") to the <code>SimpleXMLElement</code> constructor, so currently I'm passing in the XML for the outermost tag, and then building from there. Here's my code:</p>
  
  <pre><code>// Start with a "blank" XML document.
  $xml = new SimpleXMLElement("&lt;feature&gt;&lt;/feature&gt;");
  
  // Add various children and attributes to the main tag.
  $xml-&gt;addAttribute("id", $id);
  $xml-&gt;addChild("title", $feature['title']);
  $xml-&gt;addChild("summary", $feature['summary']);
  // ...
  
  // After the document has been constructed, echo out the XML.
  echo $xml-&gt;asXML();
  </code></pre>
  
  <p>Is there a cleaner way to do this?</p>