dom_comment_basic.phpt 705 B

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