009b.phpt 677 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. SimpleXML: foreach
  3. --SKIPIF--
  4. <?php if (!extension_loaded("simplexml")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. $sxe = simplexml_load_string(<<<EOF
  8. <?xml version='1.0'?>
  9. <!DOCTYPE sxe SYSTEM "notfound.dtd">
  10. <sxe id="elem1">
  11. Plain text.
  12. <elem1 attr1='first'>Bla bla 1.<!-- comment --><elem2>
  13. Here we have some text data.
  14. </elem2></elem1>
  15. <elem11 attr2='second'>Bla bla 2.</elem11>
  16. </sxe>
  17. EOF
  18. );
  19. var_dump($sxe->children());
  20. ?>
  21. ===DONE===
  22. <?php exit(0); ?>
  23. --EXPECTF--
  24. object(SimpleXMLElement)#%d (3) {
  25. ["@attributes"]=>
  26. array(1) {
  27. ["id"]=>
  28. string(5) "elem1"
  29. }
  30. ["elem1"]=>
  31. string(10) "Bla bla 1."
  32. ["elem11"]=>
  33. string(10) "Bla bla 2."
  34. }
  35. ===DONE===