【发布时间】:2012-01-30 15:08:05
【问题描述】:
可能重复:
XPath: How to match attributes that contain a certain string
我正在尝试使用 PHP DOM Xpath 解析一些 html,但是当元素有多个时,我在搜索类名时遇到问题。我发现如果我使用hole属性值,比如
$xpath->query('//div[@class="precodet precodeturgente"]');
它有效,但如果我这样做
$xpath->query('//div[@class="precodet"]');
它不会给我节点值。有时只有一个类,有些则不止一个,所以我想知道是否有办法搜索单个类名。
【问题讨论】: