[jdom-interest] XMLOutputter.outputElementContent bug?

Mark Ayad mayad at ogilvy.net
Mon Apr 23 02:06:13 PDT 2001


Hello all,

I have tried to use outputElementContent on a jdom element
to print the elements contents using a writer to the system
out, but nothing happens.

outputter.outputElementContent(header,new OutputStreamWriter(System.out));

Any suggestions out there ?

Regards

Mark

*************** example java test *********************


// import java classes
import java.io.*;

// import jdom classes
import org.jdom.*;
import org.jdom.output.XMLOutputter;
import org.jdom.input.SAXBuilder;

/**
 * simple test.xml file
 *
 * <site>
 * <header><head><title>jdom is excellent</title></head></header>
 * <footer/>
 * </site>
 */
public class JdomUnitTest
{
  /** */
  public static void main(String args[])
  {
    SAXBuilder builder = new
SAXBuilder("org.apache.xerces.parsers.SAXParser");

    try
    {
      Document doc = builder.build(new File("test.xml"));

      Element root = doc.getRootElement();

      Element header = root.getChild("header");

      XMLOutputter outputter = new XMLOutputter();

      // this works
      //outputter.output(header,System.out);

      // this does not
      outputter.outputElementContent(header,new
OutputStreamWriter(System.out));

    }
    catch(JDOMException e)
    {
      // error thrown
    }
    catch(IOException i)
    {
      // error thrown
    }

  }
}




More information about the jdom-interest mailing list