advanced_html_dom icon indicating copy to clipboard operation
advanced_html_dom copied to clipboard

text() can output extra line breaks

Open chrisjj opened this issue 8 years ago • 2 comments

This code

$html = str_get_html('<html><table><tr><td>1
<td>2<tr><td>3<td></body></html>');
var_dump($html->find('tr',0)->text());

on advanced_html_dom.php 0.0.11 outputs

string(4) "1
2"

whereas for compatibility with simple_html_dom.php (e.g. 1.5 ($Rev: 196 $)) it should output:

string(4) "1  2"

chrisjj avatar Dec 11 '16 03:12 chrisjj

Yeah, that's a side effect of DomDocument, if you want you can use clean_text method: $html->find('tr',0)->clean_text and that will squeeze all spaces and trim it.

monkeysuffrage avatar Dec 11 '16 03:12 monkeysuffrage

Thanks for the workaround.

chrisjj avatar Dec 11 '16 03:12 chrisjj