Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;

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

public class Main {
    public static Element addNode(Document doc, Node parent, String name) {
        Element child = doc.createElement(name);
        parent.appendChild(child);
        return child;
    }

    public static void addNode(Document doc, Node parent, String name, String text) {
        Element child = doc.createElement(name);
        child.appendChild(doc.createTextNode(text));
        parent.appendChild(child);
    }

    public static void addNode(Document doc, Node parent, String ns, String name, String text, Map NS_MAP) {
        Element child = doc.createElementNS((String) NS_MAP.get(ns), ns + ":" + name);
        child.appendChild(doc.createTextNode(text));
        parent.appendChild(child);
    }
}