< span="">Simplehtmldom_1_5
Create DOM from URL or file$html = file_get_html (' http://www.google.com/');//Find All images foreach ($html->find (' I MG ') as $element) Echo $element->src. '
';//Find All links foreach ($html->find (' a ') as $element) Echo $element->href. '
';
Create DOM from string$html = str_get_html (' HelloWorld '); $html->find (' div ', 1)->class = ' bar '; $html->find (' Div[id=hello] ', 0)->innertext = ' foo '; echo $html; Output:fooworld
Dump contents (without tags) from Htmlecho file_get_html (' http://www.google.com/')->plaintext;
Create DOM from url$html = file_get_html (' http://slashdot.org/');//Find All article Blocksforeach ($html->find (' Div.article ') as $article) { $item [' title '] = $article->find (' Div.title ', 0)->plaintext; $item [' intro '] = $article->find (' Div.intro ', 0)->plaintext; $item [' details '] = $article->find (' Div.details ', 0)->plaintext; $articles [] = $item;} Print_r ($articles);
http://www.bkjia.com/PHPjc/440130.html www.bkjia.com true http://www.bkjia.com/PHPjc/440130.html techarticle simplehtmldom_1_5//Create DOM from URL or file$html = file_get_html (' http://www.google.com/'),//Find all images for Each ($html-find (' img ') as $element) echo $element-src. ' BR ';