1 21 22 package nu.xom.samples; 23 24 import java.io.IOException ; 25 26 import nu.xom.Builder; 27 import nu.xom.Document; 28 import nu.xom.ParsingException; 29 30 31 41 public class XMLPrinter { 42 43 public static void main(String [] args) { 44 45 if (args.length <= 0) { 46 System.out.println("Usage: java nu.xom.samples.XMLPrinter URL"); 47 return; 48 } 49 50 try { 51 Builder parser = new Builder(); 52 Document doc = parser.build(args[0]); 53 System.out.println(doc.toXML()); 54 } 55 catch (ParsingException ex) { 56 System.out.println(args[0] + " is not well-formed."); 57 System.out.println(ex.getMessage()); 58 } 59 catch (IOException ex) { 60 System.out.println( 61 "Due to an IOException, the parser could not print " 62 + args[0] 63 ); 64 } 65 66 } 67 68 } | Popular Tags |