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

Go to the item from collection #122

Open
ashahabov opened this issue Apr 20, 2023 · 1 comment
Open

Go to the item from collection #122

ashahabov opened this issue Apr 20, 2023 · 1 comment

Comments

@ashahabov
Copy link

For example, the XPath /body//div returns a collection with 10 elements. Is it possible to go to the 3rd element from this collection?

XML: Goto XPath -> (/body//div)[3] doesn't work.

@pgfearo
Copy link
Member

pgfearo commented Apr 25, 2023

The Goto XPath command just manages simple XPath steps - not full XPath expressions.

Built-In Symbol Navigation

The standard VS Code Goto Symbol command is probably the closest to what you need.

After pressing Shift-CMD-O and entering div in the edit window you should something like the screenshot below:

Screenshot 2023-04-25 at 16 44 42

You can then navigate the dropdown list of div symbols. The outline (tree) view and breadcrumbs views offer other navigation methods.

Admittedly, these methods aren't too useful if you have a very large number of div elements and you want, for example, the 298th div element selected.

XPath Notebook

Another approach would be to use the companion XPath Notebook extension - unfortunately a recent change in VS Code broke direct navigation of XPath results (I've submitted an issue to fix this) but in the mean time you could copy and paste the generated XPath /html[1]/section[1]/section[1]/div[1] into the Goto XPath edit window:

Screenshot 2023-04-25 at 16 56 36

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