简体   繁体   English

具有多个非条件的 PHP xPath

[英]PHP xPath with multiple not conditions

I want to select all the images but exclude the images under id="adminbar" and the images start with or contain src="data:image我想选择所有图像但排除id="adminbar"下的图像并且图像以或包含src="data:image

<div id="wpadminbar" class="nojq nojs">
<img src="example.com/img">
<img src="example.com/img">
</div>
<img class="d-none d-lg-block" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E">
<img src="example/img.jpg">
<img src="example/img.png">

i tried this but it just excludes the images under id="adminbar"我试过这个,但它只是排除了id="adminbar"下的图像

//img[not(ancestor::div[@id="wpadminbar"])]

how to add not again to exclude all the img contain or startwith src="data:image如何添加不再排除所有img包含或以src="data:image开头

You can just add another predicate to the end of the expression, which will filter the results a second time.您可以在表达式末尾添加另一个谓词,这将再次过滤结果。 In the second predicate, use the starts-with function to check if the @src starts with data:image :在第二个谓词中,使用starts-with函数检查@src是否以data:image开头:

//img[not(ancestor::div[@id='wpadminbar'])][not(starts-with(@src, 'data:image'))]

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

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