blob: f7312885ba3271b7b25c933ac3d8e1fda4c76c15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
--TEST--
Testing reading and writing to DOMNode::textContent
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
/*
If this test is failing it is because the libxml2 library being used does
not have this bug fix from 2009:
https://github.com/GNOME/libxml2/commit/f3c06692e0d200ae0d35b5b3c31de8c56aa99ac6
The workaround if you are being hit by this is to add a <!DOCTYPE html> tag
*/
$html = <<<HTML
<div id="test"><span>hi there</span></div>
HTML;
$text = '<p>hello world ™</p>';
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadHTML($html);
$node = $dom->getElementById('test');
var_dump($node->textContent);
$node->textContent = $text;
var_dump($node->textContent == $text);
var_dump($dom->saveHTML($node));
?>
--EXPECT--
string(8) "hi there"
bool(true)
string(63) "<div id="test"><p>hello world &trade;</p></div>"
|