如何使用simple_html_dom.php获取纯文本值?
我想得到以下强元素的值“hello”,唯一唯一的值是em类名,强元素的类名可能重复,如何通过simple_html_dom.php获得“hello” 我 通过如何使用simple_html_dom.php获取纯文本值?,php,Php,我想得到以下强元素的值“hello”,唯一唯一的值是em类名,强元素的类名可能重复,如何通过simple_html_dom.php获得“hello” 我 通过 $html->find('em[class=b]') 只是“嗨”,不是我想要的,有人通过简单的html dom有好主意吗?谢谢 <strong class="a"> <em class="b">hi</em> hello </strong> 你好 你好 试试这个: $elem
$html->find('em[class=b]')
只是“嗨”,不是我想要的,有人通过简单的html dom有好主意吗?谢谢
<strong class="a">
<em class="b">hi</em>
hello
</strong>
你好
你好
试试这个:
$element = $html->find('em[class=a]');
$element->innertext;
实际上我还没有测试过,但它应该可以基于看看这个库或Hi Vince,谢谢你的回复,我已经尝试过了,但它不起作用。还有其他建议吗?谢谢