Here you can find the source of createXmlReader()
Parameter | Description |
---|---|
SAXException | an exception |
ParserConfigurationException | an exception |
public static XMLReader createXmlReader() throws SAXException, ParserConfigurationException
//package com.java2s; /*//from w ww . j a v a 2 s . co m * JBoss, Home of Professional Open Source. * * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. * * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. */ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; public class Main { /** * Creates an XMLReader with default feature set. * * @return XMLReader * @throws SAXException * @throws ParserConfigurationException */ public static XMLReader createXmlReader() throws SAXException, ParserConfigurationException { SAXParserFactory spf = SAXParserFactory.newInstance(); // Create a JAXP SAXParser SAXParser saxParser = spf.newSAXParser(); // Get the encapsulated SAX XMLReader XMLReader reader = saxParser.getXMLReader(); // set default features reader.setFeature("http://xml.org/sax/features/namespaces", true); return reader; } }