Created
December 7, 2012 10:58
-
-
Save pschultz/4232482 to your computer and use it in GitHub Desktop.
DomDocument::$preserveWhitespace and ::saveHtml()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$doc = new DomDocument; | |
$doc->preserveWhitespace = true; | |
$doc->formatOutput = false; | |
$doc->loadHtml( | |
'<ul id="ProjectSubmenu"> | |
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li> | |
<li> | |
<a href="/projects/markdown/basics" title="Markdown Basics">Basics</a> | |
</li> | |
<li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li> | |
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li> | |
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li> | |
</ul>' | |
); | |
$listNode = $doc->getElementsByTagName('ul')->item(0); | |
echo $doc->saveHtml($listNode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="ProjectSubmenu"> | |
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li> | |
<li> | |
<a href="/projects/markdown/basics" title="Markdown Basics">Basics</a> | |
</li> | |
<li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li> | |
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li> | |
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment