Here you can find the source of parseOptionString(Node node)
public static String parseOptionString(Node node)
//package com.java2s; import java.util.Objects; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static String parseOptionString(Node node) { Node str = parseOptionNode(node); if (str == null) { return null; } else {//from w ww. jav a2 s .co m return parseString(str); } } public static Node parseOptionNode(Node node) { Objects.requireNonNull(node); if (!(node instanceof Element) || !node.getNodeName().equalsIgnoreCase("option")) { throw new IllegalArgumentException("Node is not option: " + node); } Element e = (Element) node; if (e.hasAttribute("val")) { String val = e.getAttribute("val"); if (val.equalsIgnoreCase("some")) { if (!e.hasChildNodes()) { throw new IllegalArgumentException( "Doesn't have children: " + e); } return e.getFirstChild(); } else { return null; } } else { return null; } } public static String parseString(Node node) { Objects.requireNonNull(node); if (!node.getNodeName().equalsIgnoreCase("string")) { throw new IllegalArgumentException("Node is not string: " + node); } return node.getTextContent(); } }