how to handle DOM in PHP
Posted
by From.ME.to.YOU
on Stack Overflow
See other posts from Stack Overflow
or by From.ME.to.YOU
Published on 2010-04-07T00:12:45Z
Indexed on
2010/04/07
0:23 UTC
Read the original article
Hit count: 409
my PHP code
$dom = new DOMDocument();
@$dom->loadHTML($file);
$xpath = new DOMXPath($dom);
$tags = $xpath->query('//div[@class="text"]');
foreach ($tags as $tag) {
echo $tag->textContent;
}
what i'm trying to do here is to get the content of the div that has class 'text' but the problem when i loop and echo the results i only get the text i can't get the HTML code with images and all the HTML tags like p, br,img... etc i tried to use $tag->nodeValue; but also nothing worked out
any help !!?
© Stack Overflow or respective owner