Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    /**
     * Returns the content of the specified node.
     * <p>
     * Example:
     *
     * <pre>
     * {@code <name>John</name>
     * 
     * getContent(name); // returns "John"}
     * </pre>
     *
     * @param node
     *            The node to get the field child from.
     * @return The content of the specified node, or {@code null} if no such content exists.
     */
    public static String getContent(Node node) {
        Node fieldNode = node.getFirstChild();
        if (fieldNode == null) {
            return null;
        }
        return fieldNode.getNodeValue();
    }
}