$xpath = new DOMXPath($dom);
$imgs = $xpath->evaluate("/html/body//img");
foreach($imgs as $img)
echo '<br />' . $img->getAttribute('src');
Not tested, there is prolly a quicker way.
Oh you, that's what I was going to post, exactly that, ever since Salathe showed me some DOMDocument code I've been using this method ever since
"The reasonable man adapts himself to the conditions that surround him... The unreasonable man adapts surrounding conditions to himself... All progress depends on the unreasonable man." - George Bernard Shaw
at the top, alternatively you could use the pesky '@' error suppression operator, but I wouldn't condone it!
p.s. They are warnings not errors , sorry i'm a bit pedantic like that.
No, don't do that. They'll silence more than you want to keep quiet. If you want the XML parser to stay shushed, you can turn on user-error-handling for libxml temporarily whilst you parse the markup, then turn it off again to handle errors normally after you're finished.
libxml_use_internal_errors(TRUE); // Shhhut up!
libxml_use_internal_errors(FALSE); // Ok, you can complain now.
The Following 3 Users Say Thank You to Salathe For This Useful Post:
thanks for the help
but when i use that code, i just get images from the link i give , i want the code to spread on the website , and get all images on the whole website , not just the page i give it
i hope you understand what i mean
Break the process down into easy steps, we're not here to write all of your code for you! If you have a specific issue, please feel free to ask but I for one would rather not give you everything on a plate.
You already know a basic requirement ("get all links in all pages on that website") so have a think about how you'd do that.