Annotation of embedaddon/php/ext/simplexml/tests/006.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SimpleXML: foreach
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: $sxe = simplexml_load_string(<<<EOF
! 9: <?xml version='1.0'?>
! 10: <!DOCTYPE sxe SYSTEM "notfound.dtd">
! 11: <sxe id="elem1">
! 12: Plain text.
! 13: <elem1 attr1='first'>
! 14: Bla bla 1.
! 15: <!-- comment -->
! 16: <elem2>
! 17: Here we have some text data.
! 18: <elem3>
! 19: And here some more.
! 20: <elem4>
! 21: Wow once again.
! 22: </elem4>
! 23: </elem3>
! 24: </elem2>
! 25: </elem1>
! 26: <elem11 attr2='second'>
! 27: Bla bla 2.
! 28: <elem111>
! 29: Foo Bar
! 30: </elem111>
! 31: </elem11>
! 32: </sxe>
! 33: EOF
! 34: );
! 35:
! 36: foreach($sxe as $name => $data) {
! 37: var_dump($name);
! 38: var_dump(trim($data));
! 39: }
! 40:
! 41: echo "===CLONE===\n";
! 42:
! 43: foreach(clone $sxe as $name => $data) {
! 44: var_dump($name);
! 45: var_dump(trim($data));
! 46: }
! 47:
! 48: echo "===ELEMENT===\n";
! 49:
! 50: foreach($sxe->elem11 as $name => $data) {
! 51: var_dump($name);
! 52: var_dump(trim($data));
! 53: }
! 54:
! 55: echo "===COMMENT===\n";
! 56:
! 57: foreach($sxe->elem1 as $name => $data) {
! 58: var_dump($name);
! 59: var_dump(trim($data));
! 60: }
! 61:
! 62: ?>
! 63: ===DONE===
! 64: --EXPECT--
! 65: string(5) "elem1"
! 66: string(10) "Bla bla 1."
! 67: string(6) "elem11"
! 68: string(10) "Bla bla 2."
! 69: ===CLONE===
! 70: string(5) "elem1"
! 71: string(10) "Bla bla 1."
! 72: string(6) "elem11"
! 73: string(10) "Bla bla 2."
! 74: ===ELEMENT===
! 75: string(6) "elem11"
! 76: string(10) "Bla bla 2."
! 77: ===COMMENT===
! 78: string(5) "elem1"
! 79: string(10) "Bla bla 1."
! 80: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>