Using curl_multi_init
and querypath in a php environment, I am querying multiple websites and then reading the query results which should all be all HTML format. I process the results by using curl_multi_getcontent()
. When using the results as input for Querypath to manually parse the results, I get this error:
DOMDocument::loadHTML(): Argument #1 ($source) must not be empty ...
This is my code:
[... running in a loop for every request]
$results = curl_multi_getcontent ($curl_arr[$i]);
$htmlString = (string) $results; //casting the result to string
//echo $htmlString; //gives me the correct html result!
//echo strlen($htmlString); //proves that string is not empty!?
$qp = QueryPath::withHTML($htmlString); //this line is causing the error
I don't know what I might be missing. Any hints?
It seems that I ran into an encoding problem. It worked once I changed
$htmlString = (string) $results;
into$htmlString = utf8_decode($results);