Bug #69097 [Opn->Nab]: DOMNode->textContent completely ignores <br> newlines.

From: Date: Sat, 21 Feb 2015 11:46:55 +0000
Subject: Bug #69097 [Opn->Nab]: DOMNode->textContent completely ignores <br> newlines.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190867@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69097&edit=1

 ID:                 69097
 Updated by:         requinix@php.net
 Reported by:        divinity76 at gmail dot com
 Summary:            DOMNode->textContent completely ignores <br>
                     newlines.
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            DOM XML related
 Operating System:   insignificant
 PHP Version:        5.6.6
 Block user comment: N
 Private report:     N

 New Comment:

Keeping in mind that it is defined by the DOM standards,
http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent

textContent does not involve interpreting the meaning of elements. It is strictly just the text
content of nodes, and <br>s have no content.


Previous Comments:
------------------------------------------------------------------------
[2015-02-21 11:34:05] divinity76 at gmail dot com

$domd->loadHTML(preg_replace('/<br\\s*?\/??>/i', PHP_EOL, $html));

seems to work

------------------------------------------------------------------------
[2015-02-21 11:15:35] divinity76 at gmail dot com

it is bothering me right now, does anyone know a workaround?

------------------------------------------------------------------------
[2015-02-21 11:09:49] divinity76 at gmail dot com

Description:
------------
DOMNode->textContent created with DOMDocument->loadHTML completely ignores <br>
newlines.

i guess Bug #32581
could be related, but this is for PHP5/7, that's for PHP4

Test script:
---------------
<?php
$domd=new DOMDocument();
$domd->loadHTML("<pre>line1<br/>line2\nline3</pre>");
var_dump($domd->textContent);

Expected result:
----------------
string(17) "line1
line2
line3" //<<expected result when newlines are 1 byte long

Actual result:
--------------
string(16) "line1line2
line3"//<<actual result when newlines are 1 byte long


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69097&edit=1


Thread (4 messages)

« previous php.bugs (#190867) next »