DocumentBuilderFactory setIgnoringComments() Method
Description
The Javax.xml.parsers.DocumentBuilderFactory.setIgnoringComments(boolean ignoreComments) method specifies that the parser produced by this code will ignore comments. By default the value of this is set to false .
Declaration
Following is the declaration for Javax.xml.parsers.DocumentBuilderFactory.setIgnoringComments() method
public void setIgnoringComments(boolean ignoreComments)
Parameters
ignoreComments − boolean value to ignore comments during processing
Return Value
This method does not return a value.
Exception
NA
Example
The following example shows the usage of Javax.xml.parsers.DocumentBuilderFactory.setIgnoringComments() 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();
// change this configuration
factory.setIgnoringComments(true);
// check if factory is ignoring comments
System.out.println("" + factory.isIgnoringComments());
}
}
If we compile the code and execute it, this will produce the following result −
true
javax_xml_parsers_documentbuilderfactory.htm
Advertisements