XML Java

import org.w3c.dom.Node;
public class Util{
  public static String getTextValue(Node node) {
    StringBuffer textValue = new StringBuffer();
    int length = node.getChildNodes().getLength();
    for (int i = 0; i < length; i ++) {
      Node c = node.getChildNodes().item(i);
      if (c.getNodeType() == Node.TEXT_NODE) {
        textValue.append(c.getNodeValue());
      }
    }
    return textValue.toString().trim();
  }
  
}