Here you can find the source of createXMLReader(boolean validating, boolean withNamespace)
Parameter | Description |
---|---|
validating | true if a validating parser is desired |
withNamespace | true if the parser is namespace aware |
Parameter | Description |
---|---|
SAXException | If no XMLReader could be created. |
public static XMLReader createXMLReader(boolean validating, boolean withNamespace) throws SAXException
//package com.java2s; /***************************************************************************** * Copyright (c) 2006-2013, Cloudsmith Inc. * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the copyright holder * listed above, as the Initial Contributor under such license. The text of * such license is available at www.eclipse.org. *****************************************************************************/ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; public class Main { private static final SAXParserFactory parserFactory = SAXParserFactory.newInstance(); /**//from ww w . j a va 2 s. c o m * Create an XMLReader instance. * * @param validating * true if a validating parser is desired * @param withNamespace * true if the parser is namespace aware * @return The created instance. * @throws SAXException * If no XMLReader could be created. */ public static XMLReader createXMLReader(boolean validating, boolean withNamespace) throws SAXException { try { synchronized (parserFactory) { parserFactory.setValidating(validating); parserFactory.setNamespaceAware(withNamespace); return parserFactory.newSAXParser().getXMLReader(); } } catch (ParserConfigurationException e) { throw new SAXException(e); } } }