xref: /PHP-7.4/ext/xmlreader/tests/next_basic.phpt (revision 4cfa01bf)
1--TEST--
2XMLReader: next basic
3--SKIPIF--
4<?php if (!extension_loaded("xmlreader")) print "skip XMLReader extension required"; ?>
5--FILE--
6<?php
7
8$xml = '<?xml version="1.0" encoding="UTF-8"?><nodes><node1><sub /></node1>
9<node2><sub /></node2><node3><sub /></node3><node4><sub /></node4></nodes>';
10
11$reader = new XMLReader();
12$reader->read();
13$reader->next();
14$reader->close();
15
16$reader->XML($xml);
17$reader->read();
18$reader->read();
19echo $reader->name . PHP_EOL;
20var_dump($reader->next('node3'));
21echo $reader->name . PHP_EOL;
22var_dump($reader->next());
23echo $reader->name . PHP_EOL;
24var_dump($reader->next('node5'));
25echo $reader->name . PHP_EOL;
26var_dump($reader->next());
27echo $reader->name . PHP_EOL;
28$reader->close();
29
30?>
31--EXPECTF--
32Warning: XMLReader::read(): Load Data before trying to read in %s on line %d
33
34Warning: XMLReader::next(): Load Data before trying to read in %s on line %d
35node1
36bool(true)
37node3
38bool(true)
39node4
40bool(false)
41
42bool(false)
43