I am trying to scrap some content from a website but the code below is not working(not showing any output). here is the code
$url=\"some url\";
$otherHeader
(Try the following both in combination with and separately from the other answers, as they are other possible caveats.)
If your XPath isn't working, try applying just parts of it to make sure you are indeed following the right path. So do something like:
$path1="//body";
$item1 = $xpath->query($path1);
foreach ($item1 as $t) {
// to see the full XML of the returned node, as the nodeValue may be empty
echo $t->ownerDocument->saveXML($t);
}
Then keep increasing your XPath to the location you want.
Also, if you find that nodeValue and textContent of your nodes are empty, you should make sure that you are loading into the DOMDocument with the correct encoding (e.g. if the cURL response returns UTF-8, you'll need to pass 'UTF-8' as the second parameter when constructing your DOMDOcument).