1 9 10 package org.dom4j.samples; 11 12 import java.util.Iterator ; 13 import java.util.List ; 14 15 import org.dom4j.Attribute; 16 import org.dom4j.Document; 17 18 25 public class LinkChecker extends SAXDemo { 26 27 public static void main(String [] args) { 28 run(new LinkChecker(), args); 29 } 30 31 public LinkChecker() { 32 } 33 34 protected void process(Document document) throws Exception { 35 36 List list = document.selectNodes("//*[local-name()='a']/@href"); 37 38 System.out.println("Found: " + list.size() + " links(s)"); 39 40 for (Iterator iter = list.iterator(); iter.hasNext();) { 41 Attribute attribute = (Attribute) iter.next(); 42 System.out.println("href = " + attribute.getValue()); 43 } 44 } 45 } 46 47 85 | Popular Tags |