0

I have the following this weather site

And i need to using Xpath but icant return query!

I'm using this xPath and must return 2 Row

$xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[1]/td[1]/font/font/b');

but not return anythings:

please complete this xpath

i'm using this cod butt show error

Catchable fatal error: Object of class DOMNodeList could not be converted to string in /home/mysite/curl.php on line 23

<?php
$url="http://www.irimo.ir/farsi/current/index.asp?station=40770";
function file_get_contents_curl($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

$dom = new DomDocument();
@$dom->loadHTML($allcont);
$xpath = new DomXPath($dom);

$return = $xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[3]/td/font/b');

echo $return;
echo $xpath;

?>
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
rezad
  • 11
  • 3
  • possible duplicate of [Why does my XPath query (scraping HTML tables) only work in Firebug, but not the application I'm developing?](http://stackoverflow.com/questions/18241029/why-does-my-xpath-query-scraping-html-tables-only-work-in-firebug-but-not-the) – Jens Erat Oct 12 '14 at 17:50

1 Answers1

0

Try

$xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[3]/td/font/b');
Shoan
  • 4,003
  • 1
  • 26
  • 29
  • work but show **error**`Catchable fatal error: Object of class DOMXPath could not be converted to string in /home/Mysite` how convert to str i try strval but dont work!!! – rezad Aug 12 '11 at 21:10
  • I need to see the line that throws this error. What are you trying to do with `$xpath`? – Shoan Aug 13 '11 at 03:59