Re: Can I get document.links in JavaXPCOM ?
Carfield Yim <[email protected]> Tue, 03 Jul 2007 12:02:14 -0000
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <1183464134.465379.207240__31831.1518327848$1183464368$gmane$org@z28g2000prd.googlegroups.com> |
HI, is that I cannot get absolute URLs using htmlDoc.getLinks()? I've tried to use the following code but I can still just get the relative URLs, why will that happened? On 6 22 , 12 30 , Carfield Yim <[email protected]> wrote: > On 6 17 , 11 33 , Michal Ceresna <[email protected]> wrote: > > > On Sunday 17 June 2007, Carfield Yim wrote: > > Hello, > > > > Can I get the list of links with document.links in JavaXPCOM? > > > sure, > > > nsIDOMDocument doc = ...; > > nsIDOMHTMLDocument htmlDoc = (nsIDOMHTMLDocument) doc.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID); > > nsIDOMHTMLCollection links = htmlDoc.getLinks(); > > > best regards, > > Michal > > Thanks , now I can get document.links and link.href. However, it is > just relative links like what I get from getElementByTagName("a") . > Can I get absolute links? > > More specific, I run the following code: > > final > nsIDOMHTMLDocument htmlDoc = (nsIDOMHTMLDocument) > doc.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID); > final > nsIDOMHTMLCollection list = htmlDoc.getLinks(); > final > List<String> links = new ArrayList<String>(); > for (int i = > 0; i < list.getLength(); i++) { > final > String nodeValue = list.item(i).getAttributes() > .getNamedItem("href").getNodeValue(); > > links.add(nodeValue); > > System.out.println(nodeValue); > } > > What I get is > > archiver/ > archiver/?fid-9.html > archiver/?tid-305790.html > archiver/?tid-364135.html > > but what I need is > > http://www.xxx.net/archiver/http://www.xxx.net/archiver/?fid-9.htmlhttp://www.xxx.net/archiver/?tid-305790.htmlhttp://www.xxx.net/archiver/?tid-364135.html