I'm using PHP and xPath to crawl into a website I own (just crawl the html not going into the server) but I get this error:
Catchable fatal error: Object of class DOMNodeList could not be converted to string in C:\wamp\www\crawler.php on line 46
I already tried echoing just that line to see what I was getting but I would just get the same error also I tried googling for the error but I, in the end, ended up in the php documentation and found out my example is exactly as the one in php documentation except I'm working with an HTML instead of a XML...so I have no idea what's wrong...here's my code...
<?php
$html = file_get_contents('http://miurl.com/mipagina#0');
// create document object model
$dom = new DOMDocument();
// load html into document object model
@$dom->loadHTML($html);
// create domxpath instance
$xPath = new DOMXPath($dom);
// get all elements with a particular id and then loop through and print the href attribute
$elements = $xPath->query("//*[@class='nombrecomplejo']");
if ($elements != null) {
foreach ($elements as $e) {
echo parse_str($e);
}
}
?>
Edit
Actually yes sorry that line was to test when I had commented other stuff...I deleted it here still have the error though.