Monday, February 13, 2012

IDEA: find by XPath

I like the idea of XPath since I've looked at it over 10 years ago. Today I came across a usage that is über cool. I had the need to find some pattern of data across a bunch of xml files, where a there is a list of maps where the list and maps are marked as read-only like in this example:

<c:list-property name="*" displayName="Installed extensions" readOnly="true" required="false">
<c:map-property name="*" displayName="Name" readOnly="true">
<c:simple-property name="module" displayName="Module name" readOnly="true"/>

Luckily IDEA offers "Find by XPath"

So I could type in my expression and have it search through the whole project.

Bildschirmfoto 2012 02 13 um 17 26 32

This looked good, but did not work. Then I remembered the little 'c:' and clicked on the "Edit context..." button, which allowed to set the correct namespace for 'c:':

Bildschirmfoto 2012 02 13 um 17 28 35

Now with the namespace correctly set, the search ran for a few seconds and found the occurrences all across my files. /me is a happy user.

No comments: