You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
855 B
Java

Outputting Xml using Jdom
package com.ack.xml.jdom;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class OutputtingXmlUsingJdom {
public static void main( String[] args ) {
try {
// use SAXBuilder to create DOM from numerous types of input
SAXBuilder builder = new SAXBuilder();
builder.setExpandEntities( true );
Document doc = builder.build( "drainpipe.xml" );
// create and configure the XMLOutputter
XMLOutputter xmlOutputter = new XMLOutputter();
xmlOutputter.setTextTrim( true );
xmlOutputter.setIndent( 2 );
xmlOutputter.setNewlines( true );
// output the text
xmlOutputter.output( doc, System.out );
}
catch( Exception ioe ) {
ioe.printStackTrace();
}
}
}