code_junkie

Call to a member function xpath() on a non-object?

Nov 12th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. $xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
  2. $html = new DOMDocument();
  3. @$html->loadHTMLFile($target_URL);
  4. $xml = simplexml_import_dom($html);
  5. $source_image = $xml->xpath($xpath);
  6. $source_image = $source_image[0]['src'];
  7.  
  8. $xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
  9. $html = new DOMDocument();
  10. @$html->loadHTMLFile($target_URL);
  11. $xml = simplexml_import_dom($html);
  12. if (!$xml) {
  13. echo 'Error while parsing the document';
  14. exit;
  15. }
  16. $source_image = $xml->xpath($xpath);
  17. $source_image = $source_image[0]['src'];
Add Comment
Please, Sign In to add comment