XML xpath from selection or location of cursor


#1

Is there a package (or a way to develop) something that would let people click into an xml document, and display the path?

For example:

<?xml version="1.0" encoding="UTF-8"?> Jeffrey Berthiaume

What I’d like is something where I can click on “Jeffrey”, maybe right click (or use a function key) and see: “note/from/name/first”

Is this possible?


#2

When posting code, make sure to highlight it and press the </> button above the editor to mark it as code.

It would definitely be possible to develop this. You would have to give the package the ability to read XML files, then the command that triggers the display will check the position of the cursor and stroll up the XML tree until it gets to the root element. As for how the user would interact with it, hyperclick provides an option, but you can also add a context menu entry or a keybinding. For a display, it might be easiest to spawn the text as a tooltip or as a Decoration with type: block and item containing a div you have created with your style rules.