title: PHP DomDocument - self closing tag and special chars
body: <p>I'm generating an <code>XML</code> file using <code>PHP</code>'s <code>DomDocument</code> but I've come unstuck at one point with a self closing tag containing html entitles.</p>
  
  <p>This is the desired output : </p>
  
  <pre><code>&lt;http-headers&gt;
     &lt;header name="Access-Control-Allow-Origin" value="*" /&gt;
  &lt;/http-headers&gt;
  </code></pre>
  
  <p>This is what I'm (incorrectly) doing right now :</p>
  
  <pre><code>$httpHeaders = $xml-&gt;createElement("http-headers");
  $icecast-&gt;appendChild($httpHeaders);
  
  $headerName = $xml-&gt;createTextNode('&lt;header name="Access-Control-Allow-Origin" value="*" /&gt;');
  $httpHeaders-&gt;appendChild($headerName);
  </code></pre>
  
  <p>Which is giving me :</p>
  
  <pre><code>&lt;http-headers&gt;&amp;lt;header name="Access-Control-Allow-Origin" value="*" /&amp;gt;&lt;/http-headers&gt;
  </code></pre>
  
  <p>I've looked at <a href="http://php.net/manual/en/domdocument.createelementns.php" rel="nofollow noreferrer">namespaces</a> and <a href="http://php.net/manual/en/domelement.setattribute.php" rel="nofollow noreferrer">attribute values</a> but it's all very confusing and also I haven't been able to find a solution that adds a self closing tag.</p>
  
  <p>Also I need to output the <code>&lt;</code> and <code>&gt;</code> chars instead of converting them to <code>&amp;lt;</code> and <code>&amp;gt;</code>.</p>
  
  <p>Could somebody point me in the right direction please?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Made some progress, adding the element in the correct way now :</p>
  
  <pre><code>$httpHeaders = $xml-&gt;createElement("http-headers");
  $icecast-&gt;appendChild($httpHeaders);
  $httpHeadersHeader = $xml-&gt;createElement("header");
  $httpHeaders-&gt;appendChild($httpHeadersHeader);
  $httpHeadersHeader-&gt;setAttribute("name", '"Access-Control-Allow-Origin" value="*"'); 
  </code></pre>
  
  <p>But it's outputting the html codes instead of the characters : </p>
  
  <pre><code>&lt;http-headers&gt;
      &lt;header name="&amp;quot;Access-Control-Allow-Origin&amp;quot; value=&amp;quot;*&amp;quot;"/&gt;
  &lt;/http-headers&gt;
  </code></pre>
  
  <p>I'm adding UTF-8 encoding before outputting but it's not helping :</p>
  
  <pre><code>$xml-&gt;encoding = 'UTF-8';
  return $xml-&gt;save('php://output');
  </code></pre>
  
  <p>How do I make it output the actual symbols instead of the codes?</p>