SAXParserFactory isNamespaceAware() Method



Description

The Javax.xml.parsers.SAXParserFactory.isNamespaceAware() method indicates whether or not the factory is configured to produce parsers which are namespace aware.

Declaration

Following is the declaration for Javax.xml.parsers.SAXParserFactory.isNamespaceAware() method

public boolean isNamespaceAware()

Parameters

NA

Return Value

This method returns true if the factory is configured to produce parsers which are namespace aware; false otherwise.

Exception

NA

Example

The following example shows the usage of Javax.xml.parsers.SAXParserFactory.isNamespaceAware() method.

package com.tutorialspoint;

import javax.xml.parsers.SAXParserFactory;

public class SAXParserFactoryDemo {

   public static void main(String[] args) {

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

      try {

         // check if our factory parsers are namespace aware
         System.out.println("" + factory.isNamespaceAware());

         // change this setting
         factory.setNamespaceAware(true);

         // check if our factory parsers are namespace aware
         System.out.println("" + factory.isNamespaceAware());

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

   }
}

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

false
true
javax_xml_parsers_saxparserfactory.htm
Advertisements