When using PHP Simple HTML DOM Parser, is it normal that line breaks
tags are stripped out?
I know this is old, but I was looking for this as well, and realized there was actually a built in option to turn off the removal of line breaks. No need to go editing the source.
The PHP Simple HTML Dom Parser's load
function supports multiple useful parameters:
load($str, $lowercase=true, $stripRN=false, $defaultBRText=DEFAULT_BR_TEXT)
When calling the load
function, simply pass false
as the third parameter.
$html = new simple_html_dom();
$html->load("stuff", true, false);
If using file_get_html
, it's the ninth parameter.
file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT)
Edit: For str_get_html
, it's the fifth parameter (Thanks yitwail)
str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)