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