-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
CSS identifier escapes are not supported #838
Comments
It's not about a hyphen. Slashes cause this exception. You need a correct css selector.
Using getElementById() works just by chance because it doesn't check correctness of argument. |
Thanks for your reply. Its not xpath, its just an actual id in the
document that I have to process. Escaping doesn't work either. I'll have
to go the document's author and see if they can change the ids...
…On 23/02/2017 19:41, krystiangor wrote:
It's not about a hyphen. Slashes cause this exception. You need a
correct css selector expression, not xpath. If you're sure your
expression is correct try to escape slashes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#838 (comment)>, or
mute the thread
<https://github.com/notifications/unsubscribe-auth/AER-EZuUzlVvCtKN2a2Cy1GBjK1kGZB_ks5rfcSugaJpZM4MJ5td>.
|
Looks like the method to parse CSS identifiers is incomplete. jsoup/src/main/java/org/jsoup/parser/TokenQueue.java Lines 365 to 376 in f28c024
The linked version of the CSS specification (CSS2) contains this:
So the |
I'm not sure if it should be its own issue or not, but the incompleteness of
Throws Because the .cssSelector just creates invalid selectors in its chain and executes them: jsoup/src/main/java/org/jsoup/nodes/Element.java Lines 532 to 534 in f28c024
|
Enables the example in #838 by @DulithaRanatunga to work
This works now with bc2181d and preceding commit. Thanks! |
Hi,
when trying to do a select on a document using an id containing a hyphen, I get the following error:
Exception in thread "main" org.jsoup.select.Selector$SelectorParseException: Could not parse query '#ProductSummary-/productsummary/legalEntityId': unexpected token at '/productsummary/legalEntityId'
at org.jsoup.select.QueryParser.findElements(QueryParser.java:198)
at org.jsoup.select.QueryParser.parse(QueryParser.java:65)
at org.jsoup.select.QueryParser.parse(QueryParser.java:39)
at org.jsoup.select.Selector.(Selector.java:86)
at org.jsoup.select.Selector.select(Selector.java:108)
at org.jsoup.nodes.Element.select(Element.java:296)
This seems to have been fixed before: see issue #15 .
I am using version 1.10.2.
Using getElementById() works fine, though.
The text was updated successfully, but these errors were encountered: