View RSS Feed

My Java Tips

  1. Using the DocumentBuilderFactory

    by , 11-28-2011 at 08:02 PM (My Java Tips)
    In this post, I will present an example to show how to use the DocumentBuilderFactory.


    First step is to import the required classes.

    Java Code:
    import java.io.File;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    
    // JAXP
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.DocumentBuilderFactory;
    ...
    Categories
    Java EE
  2. Working with the DOM parser

    by , 11-28-2011 at 07:59 PM (My Java Tips)
    You will be introduced to the working of DOM parser in this post.


    We can get a DocumentBuilder instance as soon as we have a DOM factory. The methods available for the DocumentBuilder instance are very similar to those available to its SAX counterpart. But there is a slight difference when we talk about the parse() method. The parse method in case of DOM do not take an instance of the SAX DefaultHandler class. It returns a DOM Document instance representing the XML document that was ...
    Categories
    Java EE