I was experimenting around with XPath, basically I'm trying to load a HTML page using XMLHttpRequest and select an element inside it from its XPath.
Here's my code (Greasemonkey/Js):
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
onload: function(responseDetails)
{
var rs = document.evaluate("/html/body/div",responseDetails.responseText,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var n = rs.snapshotItem(0);
alert(n.innerHTML);
}});
But it isn't working.
This is the error I'm getting:
uncaught exception: [Exception... "Could not convert JavaScript argument arg 1
[nsIDOMXPathEvaluator.evaluate]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"
location: "JS frame :: file:///C:/Documents%20and%20Settings/Admin/Application%20Data
/Mozilla/Firefox/Profiles/mq3w8kw4.default/extensions/%7Be4a8a97b-f2ed-450b-
b12d-ee082ba24781%7D/components/greasemonkey.js :: anonymous :: line 587" data: no]