Annotation of embedaddon/php/ext/xmlreader/tests/008.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: XMLReader: libxml2 XML Reader, DTD
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("xmlreader")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: /* $Id: 008.phpt 204555 2006-01-04 19:44:46Z rrichards $ */
! 8:
! 9: $xmlstring = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
! 10: <!DOCTYPE LIST SYSTEM "dtdexample.dtd">
! 11: <LIST>
! 12: <MOVIE ID="x200338360">
! 13: <TITLE>Move Title 1</TITLE>
! 14: <ORGTITLE/><LOC>Location 1</LOC>
! 15: <INFO/>
! 16: </MOVIE>
! 17: <MOVIE ID="m200338361">
! 18: <TITLE>Move Title 2</TITLE>
! 19: <ORGTITLE/>
! 20: <LOC>Location 2</LOC>
! 21: <INFO/>
! 22: </MOVIE>
! 23: </LIST>';
! 24:
! 25: $dtdfile = rawurlencode(dirname(__FILE__)) . '/dtdexample.dtd';
! 26: $file = dirname(__FILE__) . '/__008.xml';
! 27: file_put_contents($file, $xmlstring);
! 28:
! 29:
! 30: $reader = new XMLReader();
! 31: $reader->open($file);
! 32: $reader->setParserProperty(XMLREADER::LOADDTD, TRUE);
! 33: $reader->setParserProperty(XMLREADER::VALIDATE, TRUE);
! 34: while($reader->read());
! 35: if ($reader->isValid()) {
! 36: echo "file DTD: ok\n";
! 37: }
! 38: $reader->close();
! 39: unlink($file);
! 40:
! 41: $xmlstring = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
! 42: <!DOCTYPE LIST SYSTEM "file:///' . $dtdfile. '">
! 43: <LIST>
! 44: <MOVIE ID="x200338360">
! 45: <TITLE>Move Title 1</TITLE>
! 46: <ORGTITLE/><LOC>Location 1</LOC>
! 47: <INFO/>
! 48: </MOVIE>
! 49: <MOVIE ID="m200338361">
! 50: <TITLE>Move Title 2</TITLE>
! 51: <ORGTITLE/>
! 52: <LOC>Location 2</LOC>
! 53: <INFO/>
! 54: </MOVIE>
! 55: </LIST>';
! 56:
! 57: $reader = new XMLReader();
! 58: $reader->XML($xmlstring);
! 59:
! 60: $reader->setParserProperty(XMLREADER::LOADDTD, TRUE);
! 61: $reader->setParserProperty(XMLREADER::VALIDATE, TRUE);
! 62: while($reader->read());
! 63: if ($reader->isValid()) {
! 64: echo "string DTD: ok\n";
! 65: }
! 66: ?>
! 67: ===DONE===
! 68: --EXPECTF--
! 69: file DTD: ok
! 70: string DTD: ok
! 71: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>