Javax.xml.parsers.SAXParser.getXMLReader() Method



Description

The Javax.xml.parsers.SAXParser.getXMLReader() method returns the XMLReader that is encapsulated by the implementation of this class.

Declaration

Following is the declaration for Javax.xml.parsers.SAXParser.getXMLReader() method

public abstract XMLReader getXMLReader()

Parameters

NA

Return Value

This method returns the XMLReader that is encapsulated by the implementation of this class.

Exception

SAXException − If any SAX errors occur during processing.

Example

The following example shows the usage of Javax.xml.parsers.SAXParser.getSchema() method.

package com.tutorialspoint;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class SaxParserDemo {

   public static void main(String[] args) {

      // create a new SAXParserFactory
      SAXParserFactory factory = SAXParserFactory.newInstance();

      try {

         // get a new SAXParser
         SAXParser parser = factory.newSAXParser();

         // get the XMLReader object
         System.out.println("" + parser.getXMLReader());

      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
}

If we compile the code and execute it, this will produce the following result −

com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser@6abf2d5e
javax_xml_parsers_saxparser.htm
Advertisements