在php中的DOM中的额外值形式跨度

问题描述 投票:0回答:2

当我提取div.####时,它与我的工作正常,但是,我不知道如何提取下面的值?

<span data-ng-if="product.specialPrice" class="current-price ng-scope">
    <strong class="ng-binding">الآن 3,363</strong>
    <span class="ng-binding"> ر.س</span>
</span>

这是我如何获得div

$html2 = file_get_html("Link");

$e3 = $html2->find('div.titlemaxheight',0);
$e4 = $html2->find('div.price4',0);
php html xml parsing dom
2个回答
0
投票

我之前没有使用过file_get_html(),但我猜你可以这样做:

$html2->find(‘span.currentprice’)->find(‘strong’);

0
投票

如果你想获得<strong>中的值,你可能会这样做并得到innertext

$content = $html2->find('.current-price strong', 0);
echo $content->innertext();

如果要在<span>中获取值,可以这样做:

$content = $html2->find('.current-price span', 0);
echo $content->innertext();
© www.soinside.com 2019 - 2024. All rights reserved.