Home > Back-end >  PHP xPath with multiple not conditions
PHP xPath with multiple not conditions

Time:06-11

I want to select all the images but exclude the images under id="adminbar" and the images start with or contain src="data:image

<div id="wpadminbar" >
<img src="example.com/img">
<img src="example.com/img">
</div>
<img  src="data:image/svg xml,">
<img src="example/img.jpg">
<img src="example/img.png">

i tried this but it just excludes the images under id="adminbar"

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

how to add not again to exclude all the img contain or startwith src="data:image

CodePudding user response:

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:

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