xref: /PHP-7.2/ext/xmlreader/tests/006.phpt (revision 17ccbeec)
1--TEST--
2XMLReader: libxml2 XML Reader, moveToElement
3--SKIPIF--
4<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
5--FILE--
6<?php
7/* $Id$ */
8
9$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
10<books><book num="1"></book><test /></books>';
11
12$reader = new XMLReader();
13
14$reader->XML($xmlstring);
15
16// 2 read to get on the 2nd node
17$reader->read();
18$reader->read();
19
20if ($reader->nodeType != XMLREADER::END_ELEMENT) {
21	if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
22		$attr = $reader->moveToFirstAttribute();
23		if ($reader->moveToElement()) {
24			if ($reader->name == 'book') {
25				echo "ok\n";
26			}
27		}
28	}
29}
30
31$reader->close();
32?>
33===DONE===
34--EXPECT--
35ok
36===DONE===
37