get Document Builder with proper settings - Android XML

Android examples for XML:XML Document

Description

get Document Builder with proper settings

Demo Code


//package com.java2s;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getDocumentBuilder());
    }//from ww w.  j av  a  2  s . c  om

    public static DocumentBuilder getDocumentBuilder() {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();
        factory.setNamespaceAware(true);
        factory.setIgnoringComments(true);
        DocumentBuilder db;
        try {
            db = factory.newDocumentBuilder();
            return db;
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials