code: private static String formatXPathForJavaXPath(String xpath) throws Exception {
  		String newXPath = "";
  
  		if (xpath.startsWith("xpath=")) {
  			xpath = xpath.replace("xpath=", "");
  		}
  
  		boolean convertIndicator = true;
  		boolean onSlash = false;
  		boolean onSingleQuote = false;
  		boolean onDoubleQuote = false;
  		for (int i = 0; i < xpath.length(); i++) {
  			char c = xpath.charAt(i);
  			if (c == '/') {
  				if (!onSingleQuote && !onDoubleQuote) {
  					if (convertIndicator) {
  						if (!onSlash) {
  							onSlash = true;
  						} else {
  							onSlash = false;
  						}
  					} else {
  						convertIndicator = true;
  						onSlash = true;
  					}
  				}
  			} else if (c == '[') {
  				if (!onSingleQuote && !onDoubleQuote)
  					convertIndicator = false;
  			} else if (c == ']') {
  				if (!onSingleQuote && !onDoubleQuote)
  					convertIndicator = true;
  			} else if (c == '\'') {
  				if (!onSingleQuote)
  					onSingleQuote = true;
  				else
  					onSingleQuote = false;
  			} else if (c == '\"') {
  				if (!onDoubleQuote)
  					onDoubleQuote = true;
  				else
  					onDoubleQuote = false;
  			}
  
  			if (convertIndicator)
  				newXPath = newXPath + String.valueOf(c).toLowerCase();
  			else
  				newXPath = newXPath + String.valueOf(c);
  		}
  
  		return newXPath;
  	}
docs: Format the xpath to work with Java XPath API
  
  @param xpath
  the xpath to be formatted
  @return String the formatted xpath
  @throws Exception