node_textcontent.phpt 663 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Testing reading and writing to DOMNode::textContent
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. if (LIBXML_VERSION < 20707) die ('skip requires libxml2-2.7.7 or higher');
  7. ?>
  8. --FILE--
  9. <?php
  10. $html = <<<HTML
  11. <div id="test"><span>hi there</span></div>
  12. HTML;
  13. $text = '<p>hello world &trade;</p>';
  14. $dom = new DOMDocument('1.0', 'UTF-8');
  15. $dom->loadHTML($html);
  16. $node = $dom->getElementById('test');
  17. var_dump($node->textContent);
  18. $node->textContent = $text;
  19. var_dump($node->textContent == $text);
  20. var_dump($dom->saveHTML($node));
  21. ?>
  22. --EXPECT--
  23. string(8) "hi there"
  24. bool(true)
  25. string(63) "<div id="test">&lt;p&gt;hello world &amp;trade;&lt;/p&gt;</div>"