DocumentBuilderFactory isIgnoringElementContentWhitespace() Method



Description

The Javax.xml.parsers.DocumentBuilderFactory.isIgnoringElementContentWhitespace() method indicates whether or not the factory is configured to produce parsers which ignore ignorable whitespace in element content.

Declaration

Following is the declaration for Javax.xml.parsers.DocumentBuilderFactory.isIgnoringElementContentWhitespace() method

public boolean isIgnoringElementContentWhitespace()

Parameters

NA

Return Value

This method returns true if the factory is configured to produce parsers which ignore ignorable whitespace in element content;false otherwise.

Exception

NA

Example

The following example shows the usage of Javax.xml.parsers.DocumentBuilderFactory.isIgnoringElementContentWhitespace() method.

package com.tutorialspoint;

import javax.xml.parsers.DocumentBuilderFactory;

public class DocumentBuilderFactoryDemo {

   public static void main(String[] args) {

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

      // check if factory is ignoring whitespaces in elements
      System.out.println("" + factory.isIgnoringElementContentWhitespace());

      // change this configuration
      factory.setIgnoringElementContentWhitespace(true);

      // check if factory is ignoring whitespaces in elements
      System.out.println("" + factory.isIgnoringElementContentWhitespace());


   }
}

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

false
true
javax_xml_parsers_documentbuilderfactory.htm
Advertisements