3 ms·
Well, the big one is selecting a parent from the child.
by vlunkr 5y ago
Well, the big one is selecting a parent from the child.
- androceium 5y agoYou could do this with the :has() CSS psuedo-class[0], though inverted (select a parent that _has_ the child matching a selector). Looks like that psuedo-class has not been implemented in the kuchiki library that htmlq uses though. [0]: https://developer.mozilla.org/en-US/docs/Web/CSS/:has https://developer.mozilla.org/en-US/docs/Web/CSS/:has
- spiralx 5y agoYou can do it either way in XPath thanks to how you can use a path expression and/or predicates almost everywhere in a query # Find all elements li and select the parent element for each //li/.. # Find all element nodes with a child element named li //*[li] # Non-abbreviated queries /descendant::li/parent::* /descendant::*[child::li] # CSS using :has :has(> li)