title: PHP DOM with namespace - parsing custom tags in a HTML template
body: <p>My goal is to create a custom templating system for HTML documents in PHP. I'm using DOMDocument, but I'm having trouble getting it to recognize a custom namespace for special tags I want to introduce.</p>
  
  <p>The beginning of my test script looks like this:</p>
  
  <pre><code>$document = new DOMDocument();
  $document-&gt;loadHTML('
          &lt;div&gt;
              &lt;example:content /&gt;
          &lt;/div&gt;', LIBXML_HTML_NOIMPLIED);
  $elements = $document-&gt;getElementsByTagNameNS('example', 'content');
  </code></pre>
  
  <p>When run I get the following warning. I don't mind suppressing it if I can get the namespace to work.</p>
  
  <pre><code>Warning: DOMDocument::loadHTML(): Tag example:content invalid in Entity, line: 3 in /Users/ryanwilliams/Sites/Test XML/test.php on line 8
  </code></pre>
  
  <p>When I <code>var_dump</code> <code>$elements</code> I get the following output (it found no results).</p>
  
  <pre><code>object(DOMNodeList)#2 (1) {
    ["length"]=&gt;
    int(0)
  }
  </code></pre>
  
  <p>When I <code>echo</code> the parsed template I get the following results. Note that it stripped out the namespace.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"&gt;
  &lt;div&gt;
              &lt;content&gt;&lt;/content&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Anyone know what I need to do to get it to recognize the namespace for that element?</p>