如何更改此 xpath 以查找内容是否包含带有包含我的关键字词组的 alt 的 img 标签?
$xPath->evaluate('count(/html/body//'.$tag.'[contains(.,"'.$keyword.'")])');
使用:
boolean(//img[contains(@alt, 'yourKeywordHere')])
Run Code Online (Sandbox Code Playgroud)
查找 ( true()
, false()
) img
XML 文档中是否存在其alt
属性包含的元素'yourKeywordHere'
。
使用:
boolean(//yourTag//img[contains(@alt, 'yourKeywordHere')])
Run Code Online (Sandbox Code Playgroud)
查找名为的文档中是否有一个元素yourTag
具有img
其alt
属性包含'yourKeywordHere'
.