Example usage for org.springframework.util.xml DomUtils createContentHandler

List of usage examples for org.springframework.util.xml DomUtils createContentHandler

Introduction

In this page you can find the example usage for org.springframework.util.xml DomUtils createContentHandler.

Prototype

public static ContentHandler createContentHandler(Node node) 

Source Link

Document

Returns a SAX ContentHandler that transforms callback calls to DOM Node s.

Usage

From source file:fi.uta.infim.usaproxylogparser.UsaProxyHTTPTrafficLogParser.java

/**
 * Parses an http traffic log for HTML content.
 * @param traffic the traffic session whose log is to be parsed
 * @return Root document node/*from   w w  w.  ja  v  a2 s. c o  m*/
 * @throws ParserConfigurationException
 * @throws IOException
 * @throws SAXException
 */
Document parseLog(UsaProxyHTTPTraffic traffic) throws ParserConfigurationException, IOException, SAXException {
    Parser p = new Parser();
    // to define the html: prefix (off by default)
    p.setFeature("http://xml.org/sax/features/namespace-prefixes", true);

    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    p.setContentHandler(DomUtils.createContentHandler(doc));
    p.parse(new InputSource(getSeekedLogReader(traffic)));
    return doc;
}