blob: f9dcdeeec7e010c2909f478f4eae22304e5d4fee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
--TEST--
XMLReader: Schema validation
--SKIPIF--
<?php if (!extension_loaded('xmlreader')) die('skip');?>
<?php if (!method_exists('XMLReader','setSchema')) die('skip XMLReader::setSchema() not supported');?>
--FILE--
<?php
/* $Id$ */
$xml =<<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<items>
<item>123</item>
<item>456</item>
</items>
EOF;
$reader = new XMLReader();
$reader->XML($xml);
$reader->setSchema(dirname(__FILE__) . '/013.xsd');
while($reader->read()) {
if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'item') {
$reader->read();
var_dump($reader->value);
}
}
$reader->close();
?>
===FAIL===
<?php
$xml =<<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<foo/>
EOF;
$reader = new XMLReader();
$reader->XML($xml);
$reader->setSchema(dirname(__FILE__) . '/013.xsd');
while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
$reader->close();
?>
===DONE===
--EXPECTF--
string(3) "123"
string(3) "456"
===FAIL===
Warning: XMLReader::read(): Element 'foo': %s
===DONE===
|