Here you can find the source of firstValueOfType(Node x, String s)
public static String firstValueOfType(Node x, String s)
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String firstValueOfType(Node x, String s) { Node n = x.getFirstChild(); Node last = x.getLastChild(); while (n != null) { if (n.getNodeName().equals(s)) { NodeList nodes = n.getChildNodes(); String result = ""; for (int i = 0; i < nodes.getLength(); i++) { Node m = nodes.item(i); result += m.getNodeValue(); }/* ww w . java 2 s.co m*/ return result; } if (n == last) break; n = n.getNextSibling(); } return null; } }