【发布时间】:2018-02-01 02:07:49
【问题描述】:
我的元素看起来是两种方式之一。有些是这样的:
<p class="pricing ats-product-price">$3.97</p>
还有一些是这样的:
<p class="pricing ats-product-price"><em class="old_price">$8.97</em>$3.97</p>
如何可靠地从元素中选择 LAST 编号(在本例中为 $3.97)并忽略第一个?
我当前使用的代码是:
$prices = $xpath->query('//p[@class="pricing ats-product-price"]');
但在第二种样式的情况下,它将返回$8.973.97。我只想要$3.97。
【问题讨论】:
标签: php xml xpath domdocument