1

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

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

1
  • Your are using 2 id's: wpadminbar and adminbar. Is that correct? Commented Jun 10, 2022 at 14:35

1 Answer 1

2

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'))]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.