Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Perhaps the <a href="http://svn.beerpla.net/repos/public/PHP/SmartDOMDocument/trunk/SmartDOMDocument.class.php" rel="nofollow noreferrer">source code</a> of this will help - They're using a regex to strip out the unnecessary strings:</p> <p><a href="http://beerpla.net/projects/smartdomdocument-a-smarter-php-domdocument-class/" rel="nofollow noreferrer">http://beerpla.net/projects/smartdomdocument-a-smarter-php-domdocument-class/</a></p> <pre><code>$content = preg_replace(array("/^\&lt;\!DOCTYPE.*?&lt;html&gt;&lt;body&gt;/si", "!&lt;/body&gt;&lt;/html&gt;$!si"), "", $this-&gt;saveHTML()); return $content; </code></pre> <p><strong>saveHTMLExact()</strong> - DOMDocument has an extremely badly designed "feature" where if the HTML code you are loading does not contain <code>&lt;html&gt;</code> and <code>&lt;body&gt;</code> tags, it adds them automatically (yup, there are no flags to turn this behavior off).</p> <p>Thus, when you call $doc->saveHTML(), your newly saved content now has <code>&lt;html&gt;&lt;body&gt;</code> and <code>DOCTYPE</code> in it. Not very handy when trying to work with code fragments (XML has a similar problem).</p> <p>SmartDOMDocument contains a new function called saveHTMLExact() which does exactly what you would want – it saves HTML without adding that extra garbage that DOMDocument does.</p> <p>Also, other questions have asked similar things:</p> <p><a href="https://stackoverflow.com/questions/4879946/domdocument-savehtml-without-html-wrapper">How to saveHTML of DOMDocument without HTML wrapper?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload