-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
element>element selector does not work relative to an element #86
Comments
@frisi , I'm really not sure how version 0.9.1 did it, but to me, something like Maybe there's something for your use-case in CSS4, around
|
thanks for your detailed explanation @redapple. i replaced the relative css selects with xpath (which - for me at least - is a lot less readable ;-): broken = tree.cssselect('div.parent')[0].cssselect('> .child')
works = tree.cssselect('div.parent')[0].xpath('./*[contains(concat(" ", @class, " "), " child ")]') is there a place in the documentation to add a note on this limitation? |
Are there really no better workarounds than dropping the entire selector to XPath manually? Perhaps there is some esoteric XPath way to take an existing expression and turn it into something that means "the same but only direct children of the scope element"? |
in version 1.0.3 i get an exception when using cssselect on an element to select it's direct children
element > element
(see https://www.w3schools.com/cssref/sel_element_gt.asp)in version 0.9.1 the following worked w/o raising an exception, however it leads to an unexpected result since the second
div.child
is no direct child ofdiv.parent
>
only works when parent selector is given in the selectorA) is it a regression, that
element.cssselect('> .child')
raises an exception on recent versions?B) is there a way to select a direct child given the parent element?
The text was updated successfully, but these errors were encountered: