1 21 22 package nu.xom.samples; 23 24 import java.io.IOException ; 25 26 import nu.xom.Builder; 27 import nu.xom.Node; 28 import nu.xom.ParsingException; 29 30 31 41 public class TreeReporter { 42 43 public static void main(String [] args) { 44 45 if (args.length <= 0) { 46 System.out.println( 47 "Usage: java nu.xom.samples.TreeReporter URL" 48 ); 49 return; 50 } 51 52 TreeReporter iterator = new TreeReporter(); 53 try { 54 Builder parser = new Builder(); 55 56 Node document = parser.build(args[0]); 58 59 iterator.followNode(document); 61 62 } 63 catch (IOException ex) { 64 System.out.println(ex); 65 } 66 catch (ParsingException ex) { 67 System.out.println(ex); 68 } 69 70 } 72 private PropertyPrinter printer = new PropertyPrinter(); 73 74 public void followNode(Node node) throws IOException { 76 77 printer.writeNode(node); 78 for (int i = 0; i < node.getChildCount(); i++) { 79 followNode(node.getChild(i)); 80 } 81 82 } 83 84 } | Popular Tags |