脚本宝典收集整理的这篇文章主要介绍了Php Html Dom Parser没有得到和元素,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$htML = file_get_html($currentFile); foreach($html->find('style') as $e){ echo $e->plaintext; }
<style tyPE="text/css"> ul.gallery li.none { display:none;} ul.gallery { margin:35px 24px 0 19px;} </style> <!--<![endif]--> <style type="text/css"> body { background:#FFF url(images/bg.gif) repeat-x;} </style>
我想用内部文本获取每个元素.
谢谢
include 'simple_html_dom.PHP'; $html_string = '<style type="text/css">ul.gallery li.none { display:none;}ul.gallery { margin:35px 24px 0 19px;}</style><!--<![endif]--><style type="text/css">body { background:#FFF url(images/bg.gif) repeat-x;}</style>'; $html = str_get_html($html_string); // or file_get_html in your case $styles = array(); foreach($html->find('style') as $style) { $styles[] = $style->innertext; } echo '<PRe>'; print_r($styles);
$styles应输出:
Array ( [0] => ul.gallery li.none { display:none;}ul.gallery { margin:35px 24px 0 19px;} [1] => body { background:#FFF url(images/bg.gif) repeat-x;} )
以上是脚本宝典为你收集整理的Php Html Dom Parser没有得到和元素全部内容,希望文章能够帮你解决Php Html Dom Parser没有得到和元素所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。