Skip to content
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

Support descendant specifier in predicates #28

Closed
LeeSmet opened this issue Jan 20, 2017 · 2 comments
Closed

Support descendant specifier in predicates #28

LeeSmet opened this issue Jan 20, 2017 · 2 comments

Comments

@LeeSmet
Copy link

LeeSmet commented Jan 20, 2017

Given the following xml document

<root>
  <a><b><c>...</c></b></a>
  <a><b>...</b></a>
  <a><b>...</b></a>
  <a><b>...</b></a>
</root>

It seems like there is currently no way to specify an Xpath expression so that only the nodes get selected because they have a grandchild somewhere. I'm looking for support for something like this
//a[.//c] or alternatively //a[b/c].
Currently, such Xpath expressions fail with etree: path has invalid filter [brackets].

@beevik
Copy link
Owner

beevik commented Jan 22, 2017

Are you searching for an element that has a specific grandchild? Or an element that has any grandchild?

If the former, I think this would work: a/*/c/../..
If the latter, I think this would work: a/*/*/../..

@LeeSmet
Copy link
Author

LeeSmet commented Jan 23, 2017

I was indeed referring to the first case. Also this solution does work for me, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants