FileDocCategorySizeDatePackage
PrettyPrinter.javaAPI DocExample3006Fri Jun 02 17:16:22 BST 2000com.oreilly.xml

PrettyPrinter

public class PrettyPrinter extends Object
PrettyPrinter will output the XML document at a given URI
author
Brett McLaughlin
author
Jason Hunter
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

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();
        }