Here is a bit of my code…
$dom = new DomDocument;
$html = $newIDs[0];
$dom->validateOnParse = true;
$dom->loadHTML($html);
$dom->preserveWhiteSpace = true;
$tryID = $dom->getElementById('ID');
echo $tryID;
I am trying to get multiple specific IDs from a website, this just shows one, and I have seen this method everywhere, including on here, but when I try and print something out nothing shows up. I tried testing to see if it is reading something in with
if(!$tryID)
{
("Element not found");
}
But it never prints that out either. Lastly, I have used
echo $tryID->nodeValue;
and still nothing… anyone know what I am doing wrong?
Also, if I do get this working can I read in multiple different things to different variables on the same $dom ? If that makes ay sense.
Ok, so your solution.
For a DIV:
This will do:
Should work without the file as long as you pass a Well-Made XML or XHTML content, changing
to your
Oh yeah, and of course, to CHANGE the content (For completeness):
Then you can just Echo it again or something.