Annotation of embedaddon/php/ext/xmlreader/tests/012.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: XMLReader: accessing empty and non existing attributes
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("xmlreader")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: /* $Id: 012.phpt 316311 2011-09-07 09:19:28Z pajoye $ */
! 8:
! 9: $xmlstring =<<<EOF
! 10: <?xml version="1.0" encoding="UTF-8"?>
! 11: <foo bar=""/>
! 12: EOF;
! 13:
! 14: $reader = new XMLReader();
! 15: $reader->XML($xmlstring);
! 16: $reader->read();
! 17: var_dump($reader->getAttribute('bar'));
! 18: var_dump($reader->getAttribute('baz'));
! 19: $reader->close();
! 20:
! 21: $xmlstring =<<<EOF
! 22: <?xml version="1.0" encoding="UTF-8"?>
! 23: <!DOCTYPE foo SYSTEM "012.dtd">
! 24: <foo bar=""/>
! 25: EOF;
! 26:
! 27: $xmlstring = str_replace('012.dtd', dirname(__FILE__).'/012.dtd', $xmlstring);
! 28: if (DIRECTORY_SEPARATOR == '\\') {
! 29: $xmlstring = str_replace('\\',"/", $xmlstring);
! 30: }
! 31: $reader = new XMLReader();
! 32: $reader->XML($xmlstring);
! 33: $reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
! 34: while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
! 35: var_dump($reader->getAttribute('bar'));
! 36: var_dump($reader->getAttribute('baz'));
! 37: $reader->close();
! 38:
! 39: echo "\nUsing URI:\n";
! 40: $reader = new XMLReader();
! 41: $file = dirname(__FILE__) . '/012.xml';
! 42: if (DIRECTORY_SEPARATOR == '\\') {
! 43: $file = str_replace('\\',"/", $file);
! 44: }
! 45:
! 46: $reader->open($file);
! 47:
! 48: //$reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
! 49: while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
! 50: var_dump($reader->getAttribute('bar'));
! 51: var_dump($reader->getAttribute('baz'));
! 52: $reader->close();
! 53:
! 54: $reader = new XMLReader();
! 55: $reader->open(dirname(__FILE__) . '/012.xml');
! 56: $reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
! 57: while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
! 58: var_dump($reader->getAttribute('bar'));
! 59: var_dump($reader->getAttribute('baz'));
! 60: $reader->close();
! 61:
! 62: ?>
! 63: ===DONE===
! 64: --EXPECT--
! 65: string(0) ""
! 66: NULL
! 67: string(0) ""
! 68: string(0) ""
! 69:
! 70: Using URI:
! 71: string(0) ""
! 72: NULL
! 73: string(0) ""
! 74: string(0) ""
! 75: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>