get Contents from XML Node - Java XML

Java examples for XML:DOM Node Value

Description

get Contents from XML Node

Demo Code


//package com.java2s;
import org.w3c.dom.Node;

public class Main {
    public static String getContents(Node node) {
        String s = node.getChildNodes().item(0).getTextContent();
        if (s != null) {
            return s.trim();
        }//from w w w  . j a v  a2s  .c o m
        return null;
    }
}

Related Tutorials