Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;

public class Main {
    public static Attr createAttribute(String name) {
        Attr attribute = null;

        Document document = createDocument();
        if (document != null) {
            attribute = document.createAttribute(name);
        }

        return attribute;
    }

    public static Document createDocument() {
        Document document = null;

        try {
            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
            document = documentBuilder.newDocument();
        } catch (ParserConfigurationException ex) {
            // Ignore parser configuration errors
        }

        return document;
    }
}