Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static String getNodeContents(Node parentNode) {
        StringBuilder sb = new StringBuilder();

        NodeList childNodes = parentNode.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node node = childNodes.item(i);
            String nodeValue = node.getNodeValue();
            if (nodeValue != null) {
                sb.append(nodeValue);
            }
        }

        return sb.toString();
    }
}