Re: Cannot get nsIDOMDocument

Javier Pedemonte <[email protected]>
Newsgroups gmane.comp.mozilla.devel.oji
Message-ID <[email protected]>
Carfield Yim wrote:
> I try to get the DOM tree using following code:
> 
> 
> 					Mozilla.getInstance().initialize(new File("c:\\tools\
> \xulrunner"));
> 					final nsIWebBrowser webBrowser = (nsIWebBrowser)
> browser.getWebBrowser();
> 					final nsIDOMWindow contentDOMWindow = webBrowser
> 							.getContentDOMWindow();
> 					final nsIDOMDocument doc = contentDOMWindow.getDocument();
> 					System.out.println(doc);

You haven't called initEmbedding(), you haven't set up the window to 
draw into, you haven't loaded a page.  Basically, you need to do more 
than what you have here.

Take a look at the ATF implementation (embeds XULRunner in an Java SWT 
app): 
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.atf/components/plugins/org.eclipse.atf.mozilla.swt.browser/src/org/eclipse/swt/browser/MozillaBrowser.java?root=WebTools_Project&view=markup, 
starting with the MozillaBrowser contructor, which sets everything up.

The MozillaHelper.getMozillaInstance() call is what actually calls 
initialize() and initEmbedding(), as seen here: 
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.atf/components/plugins/org.eclipse.atf.mozilla.ide.core/src/org/eclipse/atf/mozilla/ide/core/MozillaHelper.java?revision=1.6&root=WebTools_Project&view=markup

Once you've set everything up as shown, you should be able to call 
getContentDOMWindow().


javier pedemonte
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.