开发者

css or xpath selector: elements which have any attribute with specific value

开发者 https://www.devze.com 2023-02-24 05:39 出处:网络
I want to match all elements in an HTML Dom tree which have any attribute with the value \"foo\". I开发者_如何转开发t should either be a CSS or a XPath selector.

I want to match all elements in an HTML Dom tree which have any attribute with the value "foo". I开发者_如何转开发t should either be a CSS or a XPath selector.

My naive approach would be something like this as css selector:

*[*='foo']

How is the correct syntax?


CSS does not define an attribute selector that takes a wildcard as its name.

XPath, however, does. The following expression should work:

//*[@*="foo"]
0

精彩评论

暂无评论...
验证码 换一张
取 消