Echo XML from a file, String or InputStream in Java with SAX

Here is an example how to use the XMLEchoer class, that I have refurbished from Sun’s tutorial Echoing an XML File with the SAX Parser. It is of limited use, but can be a good start learning SAX.

import lotus.domino.AgentBase;
import net.kanngard.xml.XMLEchoer;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
String xml = "Hello World";
PrintWriter writer = getAgentOutput();
writer.println("Content-type: text/xml");
XMLEchoer echoer = new XMLEchoer(writer);
} catch(Exception e) {

To get it working, you need a SAX implementation, like Apache Xerces 2. Just drop the JAR files from Xerces 2 into the jvm/lib/ext directory in your Notes or Domino installation. Restart the http task if you are testing with Domino.

[tags]Java, XML, SAX[/tags]