开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜