Listing 1. PrintFoo.java, a short command-line program that modifies the contents of the text with id “firstpara”, and then prints the document's contents to standard output.
// Bring in the DOM classes which come with Enhydra
import org.w3c.dom.html.*;
public class PrintFoo {
// We'll only define one method, to be invoked
// from the command line.
public static void main (String[] args) {
// Create an instance of our "foo" page object.
foo myfoo = new foo();
// Change the text in our "firstpara" paragraph.
myfoo.setTextFirstpara("This has been changed");
// Display the results
System.out.print(myfoo.toDocument());
}
}