Annotation of embedaddon/php/ext/simplexml/tests/026.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SimpleXML: getName()
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: $xml =<<<EOF
! 8: <people>
! 9: <person>Jane</person>
! 10: </people>
! 11: EOF;
! 12:
! 13: function traverse_xml($xml, $pad = '')
! 14: {
! 15: $name = $xml->getName();
! 16: echo "$pad<$name";
! 17: foreach($xml->attributes() as $attr => $value)
! 18: {
! 19: echo " $attr=\"$value\"";
! 20: }
! 21: echo ">" . trim($xml) . "\n";
! 22: foreach($xml->children() as $node)
! 23: {
! 24: traverse_xml($node, $pad.' ');
! 25: }
! 26: echo $pad."</$name>\n";
! 27: }
! 28:
! 29:
! 30: $people = simplexml_load_string($xml);
! 31: traverse_xml($people);
! 32:
! 33: ?>
! 34: ===DONE===
! 35: --EXPECTF--
! 36: <people>
! 37: <person>Jane
! 38: </person>
! 39: </people>
! 40: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>