Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

<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"

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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'))]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading