What am I doing wrong with xpath?

Waldschrat

New Member
test.html\[code\]<html> <body> <span> hello Joe</span> <span> hello Bob</span> <span> hello Gundam</span> <span> hello Corn</span> </body></html>\[/code\]PHP file\[code\]$doc = new DOMDocument();$doc->loadHTMLFile("test.html");$xpath = new DOMXPath($doc);$retrieve_data = http://stackoverflow.com/questions/3596807/$xpath->evaluate("//span");echo $retrieve_data->item(1);var_dump($retrieve_data->item(1));var_dump($retrieve_data);\[/code\]I am trying to use xPath to find the spans and then echo it, but it seems I cannot echo it. I tried dumping it to see if is evaluating properly, and I am not sure what does this output mean:\[code\]object(DOMElement)#4 (0) { } object(DOMNodeList)#7 (0) { }\[/code\]What does the \[code\]#4\[/code\] and \[code\]#7\[/code\] mean and what does the parenthesis mean; What is does the syntax mean?Update: This is the error I get when I try to \[code\]echo $retrieve_data;\[/code\] and \[code\]$retrieve_data->item(1);\[/code\]\[code\]Catchable fatal error: Object of class DOMNodeList could not be converted to string\[/code\]
 
Back
Top