Java tutorial
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2005 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; public class Main { /** * Get a DocumentBuilder that is namespace aware. * @return a namespace-aware DocumentBuilder. */ public static DocumentBuilder getDocumentBuilder() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setValidating(false); dbf.setXIncludeAware(false); dbf.setExpandEntityReferences(true); dbf.setCoalescing(false); //dbf.setFeature("http://xml.org/sax/features/namespaces", false); //dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); dbf.setFeature("http://xml.org/sax/features/validation", false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return dbf.newDocumentBuilder(); } }