I have exactly the same problem as in this question but I don't know how to apply that solution to my situation. My JavaScript looks like this:
var result = [];
var xpathResult = document.evaluate('" & xpathExpression & "', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var node;
while (node = xpathResult.iterateNext()) {
result.push(node);
}
result;
and when I execute it in the browser console it returns a string (or null) but how do I get that string to be returned to my AppleScript?
I have an simpler version of the JavaScript
var result = document.evaluate(''" & xpathExpression & "', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
result.singleNodeValue"
but it has the same problem - no return value. I can even do an alert() and the string is displayed in the browser but it seems impossible to get the string back to the AppleScript.
varfrom the code, but it made no difference.varfrom the first sample will definitely not work. You need to only removevarfrom the declaration ofresult. The final line,result;- doesn't make sense by itself in a javascript sense, try removing that too.