Reading and manipulating the DOM of a loaded document with JavaXPCOM and Javier Pedemonte's SWT

[email protected]
Newsgroups gmane.comp.mozilla.devel.java
Organization http://groups.google.com
Message-ID <1146167674.847253.54580__25651.7960726798$1146167745$gmane$org@y43g2000cwc.googlegroups.com>
Hello,
   I've been able to use the JavaXPCOM code at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=79213 to place a
XULRunner object within an SWT widget, and then load a URL.  I'm not
sure how to manipulate the DOM within the tree.  Once I've run the code


public static void main(String[] args) {
        org.eclipse.swt.widgets.Display display = new Display();
        org.eclipse.swt.widgets.Shell shell = new Shell(display);

        shell.setSize(400, 400);
        shell.open();

        org.eclipse.swt.browser.MozillaBrowser mb = new
MozillaBrowser(shell, SWT.NONE);
        mb.setBounds (shell.getClientArea ());

        boolean loaded = mb.setUrl( "http://www.google.com" );
        /* DOM manipulation functions follow */
}

   This code loads http://www.google.com, but once the URL is loaded,
I'm not able to manipulate the document.  As an example, to get the
number of "a" elements in the Google home page, I've tried the snippet

        nsIDOMDocument doc = mb.getDocument();
        nsIDOMNodeList aNL = doc.getElementsByTagName("a");
        long aNumber = aNL.getLength();
        System.out.println("Number of \"a\" elements: " + aNumber +
"");

but this just gives zero elements, and there are other indications that
mb.getDocument() does not return a usable representation of the
document loaded into the browser.  Does anyone have any suggestions?

   Thanks!

   Patrick
   [email protected]
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.