列表 1. PrintFoo.java,一个简短的命令行程序,它修改 id 为“firstpara”的文本内容,然后将文档的内容打印到标准输出。

// 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());
   }
}
© . All rights reserved.