Here you can find the source of parseDom(Reader reader)
Parameter | Description |
---|---|
reader | the xml reader |
public static Document parseDom(Reader reader)
//package com.java2s; //License from project: Apache License import java.io.Reader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /**// w w w . jav a 2s.c o m * Document builder factory */ private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); /** * Creates a DOM from a file representation of an xml record * * @param reader the xml reader * @return the DOM document */ public static Document parseDom(Reader reader) { try { DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new org.xml.sax.InputSource(reader)); } catch (Exception e) { throw new RuntimeException("Could not parse DOM for '" + reader.toString() + "'!", e); } } }