Created
August 5, 2014 11:07
-
-
Save Eccenux/edfb68f0e4745f16af19 to your computer and use it in GitHub Desktop.
PHP DOM parser - problem with HTML whitespace
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
<!DOCTYPE html> | |
<!-- | |
Copyright: ©2014 Nux | |
License: CC0 | |
--> | |
<html> | |
<head> | |
<title>Test</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div data-lang="en"> | |
<p>Some national characters: żść.</p> | |
<p>App version 0.1.1.</p> | |
<ul> | |
<li>Create model with JSON.</li> | |
<li>Append views to HTML</li> | |
<li>Add interactions in controllers.</li> | |
<li>Test in any browser.</li> | |
<li>Package.</li> | |
<li>Run anywhere.</li> | |
</ul> | |
</div> | |
</body> | |
</html> |
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
<!DOCTYPE html> | |
<!-- | |
Copyright: ©2014 Nux | |
License: CC0 | |
--><html><head><title>Test</title><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta charset="UTF-8"></head><body> | |
<div data-lang="en"> | |
<p>Some national characters: żść.</p> | |
<p>App version 0.1.1.</p> | |
<ul><li>Create model with JSON.</li> | |
<li>Append views to HTML</li> | |
<li>Add interactions in controllers.</li> | |
<li>Test in any browser.</li> | |
<li>Package.</li> | |
<li>Run anywhere.</li> | |
</ul></div> | |
</body></html> |
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
<?php | |
$inputFile = 'index.mini.html'; | |
$html = file_get_contents($inputFile); | |
$document = new DOMDocument(); | |
$document->loadHTML($html); | |
$parsed_html = $document->saveHTML(); | |
echo $parsed_html; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment