Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOMXPath var_dump: "(object value omitted)" [duplicate]

$store = curl_exec($ch); // Returns a page of HTML

$doc = new DOMDocument();
$doc->loadHTML($store);
$xpath = new DOMXpath($doc);

Vardump $xpath:

object(DOMXPath)#2 (1) { 
    ["document"] => string(22) "(object value omitted)" 
} 

What is wrong here? I'm trying to use xpath on the HTML code to extract info.

object(DOMDocument)#1 (34) {
    ["doctype"]         => string(22) "(object value omitted)" 
    ["implementation"]  => string(22) "(object value omitted)" 
    ["documentElement"] => string(22) "(object value omitted)" 
    ["actualEncoding"]  => string(6) "gb2312" 
    ["encoding"]        => string(6) "gb2312"
    ["xmlEncoding"]     => string(6) "gb2312" 
    ["standalone"]      => bool(true) 
    ...
like image 777
CodeGuru Avatar asked Oct 22 '22 06:10

CodeGuru


1 Answers

loadHTMLFile requires path of the html file not the content of the html file loadhtmlfile. So your code will be

$doc = new DOMDocument();
$doc->loadHTMLFile("path to html file");
$xpath = new DOMXpath($doc);

Edit

If you want to load from html content use loadhtml

$doc = new DOMDocument();
$doc->loadHTML($store);
$xpath = new DOMXpath($doc);
like image 112
Yogesh Suthar Avatar answered Oct 30 '22 21:10

Yogesh Suthar