mirror of
https://github.com/php/php-src.git
synced 2024-10-01 23:06:11 +00:00
6b896fa57f
* pull-request/320: this is test 5 not 6 fix race condition more shared names that create race conditions change to a unique filename more shared filenames yet another shared filename don't share a filename to stop race conditions fix race condition for 2-4 and normalize names for others fix race condition when running tests in parallel clean up after test Fix #64572: Clean up after the test Fix #64572: Clean up after the test
45 lines
1005 B
PHP
45 lines
1005 B
PHP
--TEST--
|
|
XMLReader: libxml2 XML Reader, attributes test
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
|
|
--FILE--
|
|
<?php
|
|
/* $Id$ */
|
|
$filename = dirname(__FILE__) . '/_004.xml';
|
|
|
|
$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
|
|
<books><book num="1" idx="2">book1</book></books>';
|
|
file_put_contents($filename, $xmlstring);
|
|
|
|
$reader = new XMLReader();
|
|
if (!$reader->open($filename)) {
|
|
exit();
|
|
}
|
|
|
|
while ($reader->read()) {
|
|
if ($reader->nodeType != XMLREADER::END_ELEMENT) {
|
|
echo $reader->name."\n";
|
|
if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
|
|
$attr = $reader->moveToFirstAttribute();
|
|
while ($attr) {
|
|
echo " Attribute Name: ".$reader->name."\n";
|
|
echo " Attribute Value: ".$reader->value."\n";
|
|
$attr = $reader->moveToNextAttribute();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$reader->close();
|
|
unlink($filename);
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
books
|
|
book
|
|
Attribute Name: num
|
|
Attribute Value: 1
|
|
Attribute Name: idx
|
|
Attribute Value: 2
|
|
#text
|
|
===DONE===
|