Pretty prints a given XML URI
if (args.length != 1) {
System.out.println("Usage: " +
"java com.oreilly.xml.PrettyPrinter [XML_URI]");
return;
}
String filename = args[0];
try {
// Build the Document with SAX and Xerces, no validation
Builder builder = new SAXBuilder();
// Create the document (with validation)
Document doc = builder.build(new File(filename));
// Output the document, use standard formatter
XMLOutputter fmt = new XMLOutputter();
fmt.output(doc, System.out);
} catch (Exception e) {
e.printStackTrace();
}