Hi Boris,
thanks for your answer.
On Jul 19, 2:17 pm, Boris Zbarsky bzbar...@mit.edu wrote:
On 7/19/11 8:55 AM, legrass wrote:
On that page,
http://www.dixonvince.com/
either using Firebug (on Firefox 3.6.17) or XPath I match 31 tags
script.
After the page has loaded and the scripts have run, right?
Yes, I run my code it when the browser progress listener triggers page
loaded.
However, in my java code (xulrunner 1.9.2), if I retrieve the
nsIDOMDocument and getElementsByTagName I get only 20 tags.
How are you retrieving it?
webBrowser.getContentDOMWindow().getDocument().getElementsByTagName(tagname)
where webBrowser is a nsIWebBrowser.
Also, if I use the nsIDOMXPathEvaluator to evaluate the //script
expression, the result is again 20 nodes.
Using what exact code, on which document?
I've been using this code for a while without problems.
String exp=count(//script);
Mozilla moz = Mozilla.getInstance();
nsIComponentManager compManager = moz.getComponentManager();
nsIDOMXPathEvaluator xpath = (nsIDOMXPathEvaluator) componentManager
.createInstanceByContractID(NS_IDOMXPATHEVALUATOR_CONTRACTID,
null,
nsIDOMXPathEvaluator.NS_IDOMXPATHEVALUATOR_IID);
nsIDOMDocument document =
getBrowser().getContentDOMWindow().getDocument();
nsISupports res =
xpath.evaluate(exp,document,xpath.createNSResolver(document),
nsIDOMXPathResult.NUMBER_TYPE,null);
// Obtain the interface corresponding to the XPath XPCOM results
object
nsIDOMXPathResult out = (nsIDOMXPathResult)
res.queryInterface(nsIDOMXPathResult.NS_IDOMXPATHRESULT_IID);
System.out.println(out.getNumberValue());
Finally, I tried to save the page with
nsIWebBrowserPersist.saveDocument and on within the file there are
indeed 20 occurrencies of script.
If you're saving the original html, then chances are some of those
scripts add other script tags to the DOM.
I though to the saveDocument as I wanted to understand what's going
on. I might be wrong using the code here.
I'm using the following flags on the nsIWebBrowserPersist object:
persist.setPersistFlags(persist.PERSIST_FLAGS_DONT_CHANGE_FILENAMES|
persist.PERSIST_FLAGS_DONT_FIXUP_LINKS|
persist.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS|
persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES);
long encflags=persist.ENCODE_FLAGS_FORMATTED;
persist.saveDocument(document,localFile,localPath,null,encflags,0);
Thanks for you help.
-Boris
___
dev-embedding mailing list
dev-embedding@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-embedding