Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * JFox - The most lightweight Java EE Application Server!
 * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
 *
 * JFox is licenced and re-distributable under GNU LGPL.
 */

import org.w3c.dom.Attr;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {

    public static Element addTextElement(Node parent, String name, String value) {
        return addTextElement(parent, name, value, null);
    }

    public static Element addTextElement(Node parent, String name, String value, Attr[] attrs) {
        Element element;
        if (parent instanceof Document) {
            element = ((Document) parent).createElement(name);
        } else {
            element = parent.getOwnerDocument().createElement(name);
        }

        if (attrs != null && attrs.length > 0) {
            for (Attr attr : attrs) {
                element.setAttributeNode(attr);
            }
        }

        if (value != null) {
            element.setTextContent(value);
        }
        parent.appendChild(element);
        return element;
    }
}