Highlight based on Xpath in xml mode

Hi, I have been working on a project which requires me to highlight an element in the XML CodeMirror browser editor based on Xpath. I searched through the API’s and there is a markText() API, but it highlights based on line numbers.

Is there a way where I can highlight the correct XPath in the browser itself.

For highlighting, a mode is usually better than an addon that actively marks text. Depending on how you want the highlighting to work, you could use an overlay or wrap another mode.