package org.wookie.qti.util; import java.io.IOException; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class DocumentBuilderHelper { public Document createDocument(String xmlIn) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setEncoding("UTF-8"); is.setCharacterStream(new StringReader(xmlIn)); Document doc = db.parse(is); doc.getDocumentElement().normalize(); return doc; } catch (SAXException e) { //TODO saxExcpetion } catch (IOException e) { //TODO something } catch (ParserConfigurationException e) { //TODO something } return null; } }