繁体   English   中英

PHP:simple_html_dom-使用类在跨度内查找文本

[英]PHP: simple_html_dom - Find text inside a span with class

给定这样的HTML:

(...)
<div class="UserLevel type_2">
    <span class="LevelNum">23</span>
</div>
(...)

给定需要的部分在LevelNum类的范围内,如何使用simple_html_dom将23作为php var LevelNum

谢谢

直接来自简单HTML DOM文档,您是否尝试过类似

$something = $object->find('span[class=LevelNum]');

你能试一下吗 :

foreach ($html->find('div[class=UserLevel type_2]') as $div);
foreach($div->find('LevelNum') as $element) 
    echo $element->innertext;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM