Heim > Artikel > Backend-Entwicklung > 读取XML获取不了节点值?
<code><?php $reader = new XMLReader(); $reader->open("1.xml"); while($reader->read()){ if($reader->nodeType==XMLREADER::ELEMENT) { if ($reader->localName == "humans") { //已经能进if语句,但是获取不了value echo $reader->value; } } } ?> </code>
XML文件1.xml:
<code><?xml version="1.0"?> <humans> hello </humans> </code>
$reader->value无效,什么原因?请教!
<code><?php $reader = new XMLReader(); $reader->open("1.xml"); while($reader->read()){ if($reader->nodeType==XMLREADER::ELEMENT) { if ($reader->localName == "humans") { //已经能进if语句,但是获取不了value echo $reader->value; } } } ?> </code>
XML文件1.xml:
<code><?xml version="1.0"?> <humans> hello </humans> </code>
$reader->value无效,什么原因?请教!
if语句少了$reader->read();