dom_comment_basic.phpt 716 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. DOM Comment : Basic Functionality
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. $xml = <<< EOXML
  10. <?xml version="1.0" encoding="ISO-8859-1"?>
  11. <courses>
  12. <!-- Hello World! -->
  13. </courses>
  14. EOXML;
  15. $dom = new DOMDocument();
  16. $dom->loadXML($xml);
  17. $root = $dom->documentElement;
  18. var_dump($root->hasChildNodes());
  19. $children = $root->childNodes;
  20. for ($index = 0; $index < $children->length; $index++) {
  21. echo "--- child $index ---\n";
  22. $current = $children->item($index);
  23. echo get_class($current), "\n";
  24. var_dump($current->textContent);
  25. }
  26. --EXPECTF--
  27. bool(true)
  28. --- child 0 ---
  29. DOMText
  30. string(2) "
  31. "
  32. --- child 1 ---
  33. DOMComment
  34. string(14) " Hello World! "
  35. --- child 2 ---
  36. DOMText
  37. string(1) "
  38. "