Q:

how to write below xpath in java

//div[@ng-if="subNav.state == 'active'"]

I tried like as below but getting "InvalidSelectorException":
String active = "subNav.state == 'active'";
driver.findElement(By.xpath("//div[@ng-if='"+active+"']"))

<li class="active" on="subNav.state != '' && subNav.state != 'active'" ng-switch="" ng-repeat="subNav in navigation[activeNav].pages | filter:subNavFilter(navigation[activeNav].pages)">
 <div class="whereabouts ng-scope" ng-if="subNav.state == 'active'"></div>
 <span class="badge badge-active" aria-disabled="true" ng-if="subNav.state != 'complete'">6</span>
 <span class="ng-binding ng-scope" ng-switch-when="false">Loan</span>
</li>

A:

If there will be quotes used inside the value you should escape the quotes.And I would suggest go with double quotes to close all.
Here's the xpath
    String active = "subNav.state == 'active'";
    driver.findElement(By.xpath("//div[@ng-if=\"" + active + "\"]"));

