views:

35

answers:

0

Hi,

I am having troubles with making my Firefox extension use xPath on a page loaded via AJAX inside my extension window.

Here https://developer.mozilla.org/en/DOM/document.evaluate it says that evaluate can be used with HTML or XML documents to evaluate xPath expression. So, i created a HTMLDocument object, assigned the AJAX response text through .innerHTML. All is good so far.

Problem came to me when i tried to evaluate this HTMLDocument object oHTML. I got an error, saying that oHTML.evaluate is not a function. Ok, so i checked how does it work with other pages, and i found out, that evaluation works with XPCNativeWrapper[HTMLDocument] object.

Here https://developer.mozilla.org/en/XPCNativeWrapper it states that i need to do the following to create a wrapper object.

var contentWinWrapper = new XPCNativeWrapper(content);

I pass oHTML as content to this constructor and what you know, i get error

Cannot convert WrappedNative to function"  nsresult: "0x8057000d
(NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)"  location: "JS frame ::
chrome://ext/content/sample.js :: anonymous :: line 155"  data: no

Mozzila developer center mentions nothing about what exactly is this content object in their example so maybe thats the problem? I have no idea what else to pass there? I thought, by content they mean HTMLDocument object.

Help me understand. Thanks