Feb
13
Posted on 2006-02-13
Filed Under (Domino/Notes, Java, XML) by Johan Känngård

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 java.io.PrintWriter;
import lotus.domino.AgentBase;
import net.kanngard.xml.XMLEchoer;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

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

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]

    Read More   
Post a Comment
Name:
Email:
Website:
Comments: