1 16 package org.apache.axis2.util; 17 18 import org.w3c.dom.Document ; 19 import org.xml.sax.SAXException ; 20 21 import javax.xml.parsers.DocumentBuilder ; 22 import javax.xml.parsers.DocumentBuilderFactory ; 23 import javax.xml.parsers.ParserConfigurationException ; 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 27 31 public class XMLUtils { 32 33 39 public static Document newDocument() 40 throws ParserConfigurationException { 41 DocumentBuilder db = null; 42 43 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 44 dbf.setNamespaceAware(true); 45 db = dbf.newDocumentBuilder(); 46 Document doc = db.newDocument(); 47 return doc; 48 } 49 50 59 public static Document newDocument(InputStream in) 60 throws ParserConfigurationException , SAXException , IOException { 61 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 62 dbf.setNamespaceAware(true); 63 DocumentBuilder db = dbf.newDocumentBuilder(); 64 return db.parse(in); 65 } 66 67 } 68 | Popular Tags |