The line
xPath = xPath.replaceAll("\"", "\\\"");
is quite important as it replaces any " character in the xPath with \" so that it prevents syntx errors in the JavaScript. I assume you are not doing this as expected ')' means that the string in getEval() is finished but no ) follows.
But you may also give me a look at the Selenium RC log. Maybe there is something else that I did not mention (and not run in on my system).
EDIT: thinking about this more ... I do not have any xPath containing ". The correct line could also be
xPath = xPath.replaceAll("\"", "\\\\\"");
but I am at home now and cannot check this.