Annotation of embedaddon/php/ext/dom/tests/dom002.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test 2: getElementsByTagName() / getElementsByTagNameNS()
! 3: --SKIPIF--
! 4: <?php require_once('skipif.inc'); ?>
! 5: --FILE--
! 6: <?php
! 7: $xml = <<<HERE
! 8: <?xml version="1.0" encoding="ISO-8859-1" ?>
! 9: <foo xmlns="http://www.example.com/ns/foo"
! 10: xmlns:fubar="http://www.example.com/ns/fubar">
! 11: <bar><test1 /></bar>
! 12: <bar><test2 /></bar>
! 13: <fubar:bar><test3 /></fubar:bar>
! 14: <fubar:bar><test4 /></fubar:bar>
! 15: </foo>
! 16: HERE;
! 17:
! 18: function dump($elems) {
! 19: foreach ($elems as $elem) {
! 20: var_dump($elem->nodeName);
! 21: dump($elem->childNodes);
! 22: }
! 23: }
! 24:
! 25: $dom = new DOMDocument();
! 26: $dom->loadXML($xml);
! 27: $doc = $dom->documentElement;
! 28: dump($dom->getElementsByTagName('bar'));
! 29: dump($doc->getElementsByTagName('bar'));
! 30: dump($dom->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));
! 31: dump($doc->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));
! 32: ?>
! 33: --EXPECT--
! 34: string(3) "bar"
! 35: string(5) "test1"
! 36: string(3) "bar"
! 37: string(5) "test2"
! 38: string(9) "fubar:bar"
! 39: string(5) "test3"
! 40: string(9) "fubar:bar"
! 41: string(5) "test4"
! 42: string(3) "bar"
! 43: string(5) "test1"
! 44: string(3) "bar"
! 45: string(5) "test2"
! 46: string(9) "fubar:bar"
! 47: string(5) "test3"
! 48: string(9) "fubar:bar"
! 49: string(5) "test4"
! 50: string(9) "fubar:bar"
! 51: string(5) "test3"
! 52: string(9) "fubar:bar"
! 53: string(5) "test4"
! 54: string(9) "fubar:bar"
! 55: string(5) "test3"
! 56: string(9) "fubar:bar"
! 57: string(5) "test4"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>