1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $page = file_get_contents('http://en.wikipedia.org/wiki/scotland'); $doc = new DOMDocument(); $doc->loadHTML($page); $divs = $doc->getElementsByTagName('div'); foreach($divs as $div) { // Loop through the DIVs looking for one withan id of "content" if ($div->getAttribute('id') === 'bodyContent' ) { echo $div->nodeValue; } } ?> |
