<HTML><P>Hi Rajesh,</P>
<P>I got this from the jdom-b7/samples katalog when I downloaded jdom-b7.zip from <A href="http://www.jdom.org">www.jdom.org</A> - check it out for more examples - the one you have requestet comes here:</P>
<P>regards</P>
<P>Soeren</P>
<P>Code:</P>
<P>*/<BR>package samples;</P>
<P>import java.io.File;<BR>import java.io.IOException;<BR>import java.io.OutputStream;</P>
<P>import org.jdom.Document;<BR>import org.jdom.JDOMException;<BR>import org.jdom.input.SAXBuilder;<BR>import org.jdom.output.XMLOutputter;</P>
<P>/**<BR> * <p><code>SAXBuilderDemo</code> demonstrates how to<BR> * build a JDOM <code>Document</code> using a SAX 2.0<BR> * parser.<BR> * </p><BR> * <BR> * @author Brett McLaughlin<BR> * @author Jason Hunter<BR> * @version 1.0<BR> */<BR>public class SAXBuilderDemo {</P>
<P> /**<BR> * <p><BR> * This provides a static entry point for creating a JDOM<BR> * <code>{@link Document}</code> object using a SAX 2.0<BR> * parser (an <code>XMLReader</code> implementation).<BR> * </p><BR> *<BR> * @param args <code>String[]</code><BR> * <ul><BR> * <li>First argument: filename of XML document to parse</li><BR> * <li>Second argument: optional name of SAX Driver class</li><BR> * </ul><BR> */<BR> public static void main(String[] args) {<BR> if ((args.length != 1) && (args.length != 2)) {<BR> System.out.println(<BR> "Usage: java samples.SAXBuilderTest " +<BR> "[XML document filename] ([SAX Driver Class])");<BR> return;<BR> }</P>
<P> // Load filename and SAX driver class<BR> String filename = args[0];<BR> String saxDriverClass = null;<BR> if (args.length == 2) {<BR> saxDriverClass = args[1];<BR> }</P>
<P> // Create an instance of the tester and test<BR> try {<BR> SAXBuilder builder = null;<BR> if (saxDriverClass == null) {<BR> builder = new SAXBuilder();<BR> } else {<BR> builder = new SAXBuilder(saxDriverClass);<BR> }<BR> Document doc = builder.build(filename);<BR> // Create an outputter<BR> XMLOutputter outputter = new XMLOutputter();<BR> //outputter.setTrimText(true);<BR> //outputter.setExpandEmptyElements(true);<BR> outputter.output(doc, System.out);<BR> } catch (JDOMException e) {<BR> if (e.getRootCause() != null) {<BR> e.getRootCause().printStackTrace();<BR> } else {<BR> e.printStackTrace();<BR> }<BR> } catch (Exception e) {<BR> e.printStackTrace();<BR> } <BR> }</P>
<P>}<BR><BR></P>
<HR>
<BLOCKQUOTE TYPE="CITE"></BLOCKQUOTE>
<HR>
<BR>___________________________________<BR><BR>Soeren Arleth - Oracle Denmark<BR><BR>EMEA Java/XML Professional Community<BR><BR>"Build a better mousetrap, and the world will<BR><BR>beat a path to your door." <BR><BR>--Emerson</HTML>