Create new DocumentBuilderFactory : DocumentBuilder « XML « Java Tutorial






import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class TryDOM {
  public static void main(String args[]) {
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try {
      builder = builderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
      System.exit(1);
    }
    System.out.println("Builder Factory = " + builderFactory + "\nBuilder = " + builder);
  }
}








33.7.DocumentBuilder
33.7.1.Create new DocumentBuilderFactory
33.7.2.New Document From InputStream
33.7.3.New Document From String