Ben XPath ile yanlış ne yapıyorum?

0 Cevap php

test.html

<html>
    <body>
        <span> hello Joe</span>
        <span> hello Bob</span>
        <span> hello Gundam</span>
        <span> hello Corn</span>
    </body>
</html>

PHP dosyası

$doc = new DOMDocument();
$doc->loadHTMLFile("test.html");

$xpath = new DOMXPath($doc);

$retrieve_data = $xpath->evaluate("//span");

echo $retrieve_data->item(1);
var_dump($retrieve_data->item(1));
var_dump($retrieve_data);

Ben açıklıklı bulmak ve sonra echo XPath kullanmaya çalışıyorum, ama ben onu echo edemez görünüyor. Ben düzgün değerlendirilmesi görmek için damping çalıştı ve ben bu çıkış ne demek emin değilim:

object(DOMElement)#4 (0) { } 
object(DOMNodeList)#7 (0) { }

#4 ve #7 ortalama ve parantez ne ne demek gelmez; Sözdizimi ne demek olduğunu?

Update: This is the error I get when I try to echo $retrieve_data; and $retrieve_data->item(1);

Catchable fatal error: Object of class DOMNodeList could not be converted to string

0 Cevap