Annotation of embedaddon/php/ext/simplexml/tests/015.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SimpleXML: accessing singular subnode as array
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: $xml =<<<EOF
! 8: <people>
! 9: <person name="Joe"></person>
! 10: </people>
! 11: EOF;
! 12:
! 13: $xml2 =<<<EOF
! 14: <people>
! 15: <person name="Joe"></person>
! 16: <person name="Boe"></person>
! 17: </people>
! 18: EOF;
! 19:
! 20: $people = simplexml_load_string($xml);
! 21: var_dump($people->person['name']);
! 22: var_dump($people->person[0]['name']);
! 23: //$people->person['name'] = "XXX";
! 24: //var_dump($people->person['name']);
! 25: //var_dump($people->person[0]['name']);
! 26: //$people->person[0]['name'] = "YYY";
! 27: //var_dump($people->person['name']);
! 28: //var_dump($people->person[0]['name']);
! 29: //unset($people->person[0]['name']);
! 30: //var_dump($people->person['name']);
! 31: //var_dump($people->person[0]['name']);
! 32: //var_dump(isset($people->person['name']));
! 33: //var_dump(isset($people->person[0]['name']));
! 34: $people = simplexml_load_string($xml2);
! 35: var_dump($people->person[0]['name']);
! 36: var_dump($people->person[1]['name']);
! 37: ?>
! 38: ===DONE===
! 39: --EXPECTF--
! 40: object(SimpleXMLElement)#%d (1) {
! 41: [0]=>
! 42: string(3) "Joe"
! 43: }
! 44: object(SimpleXMLElement)#%d (1) {
! 45: [0]=>
! 46: string(3) "Joe"
! 47: }
! 48: object(SimpleXMLElement)#%d (1) {
! 49: [0]=>
! 50: string(3) "Joe"
! 51: }
! 52: object(SimpleXMLElement)#%d (1) {
! 53: [0]=>
! 54: string(3) "Boe"
! 55: }
! 56: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>