XPath with XmlFile (PsiFile)
Hi ! I was searching for a few hours how to execute an XPath search using the Psi from Idea, but I couldn't find anything (just some methods like XmlUtil.findOnAnyLevel that could help in very simple xpaths).
Is there any way for searching with XPath on an .xml file and get the PsiElements as the result ?
Thanks !
Enrique.
Please sign in to leave a comment.
There is no support for XPath searches directly in the XML PSI API. You can look at how the XPath plugin implements its actions for XPath evaluation (XPathEvalAction) but generally that's an approach that's targeted for users, not plugin developers.
I don't have that class in my source files, and thats weird because I can see it in some imports :
I have a helper for searching an xpath right now:
If you're working on a plugin, you'll need to add the XPathView plugin jar to the classpath of the IntelliJ IDEA SDK.
DOM elements and PSI elements are two completely different representations of an XML document; there is no way to convert between them.