dom_comment_variation.phpt 608 B

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