### Question:
XmlUtil { public static String getString(Node node, String xpath) { NodeList nodeList = getNodeList(node, xpath); if (nodeList == null || nodeList.getLength() == 0) { return ""; } if (xpath.endsWith(ELEMENT_NAME_FUNC)) { if (nodeList.getLength() > 0) { return nodeList.item(0).getNodeName(); } else { return ""; } } else { return serialize(nodeList); } }  static boolean isXMLReservedNamespace(String namespace); static void removeEntities(Reader reader, Writer writer); static String removeEntities(String string); static void rewriteEntities(Reader reader, Writer writer); static Document parseStream(InputStream stream, VALIDATION_TYPE validation,
                                       boolean expandEntityRefs); static Document parseStream(InputStream stream,
                                       EntityResolver entityResolver, VALIDATION_TYPE validation,
                                       boolean expandEntityRefs); static Document parseStream(Reader stream,
                                       EntityResolver entityResolver, VALIDATION_TYPE validation,
                                       boolean expandEntityRefs); static Document parseStream(InputStream stream); static Document parseStream(Reader stream); static Document parseStream(Reader stream, final ErrorHandler errorHandler); static NodeList getNodeList(Node node, String xpath); static Node getNode(Node node, String xpath); static String getString(Node node, String xpath); static Element createElement(String localPart); static Element createElementNS(String namespace, String localPart); static String serialize(NodeList nodeList); static String serialize(final Node node, boolean format); static void serialize(final Node node, boolean format, Writer writer); static String serialize(NodeList nodeList, boolean format); static void serialize(NodeList nodeList, boolean format, Writer writer); static String indent(String xml, int indent); static boolean isTextNode(Node node); static void encodeTextValue(char[] characters, int offset, int length, Writer writer); static void encodeAttributeValue(char[] characters, int offset, int length, Writer writer); static final DocumentBuilder documentBuilder; static final char[] LT; static final char[] GT; static final char[] AMP; static final char[] QUOT; static final char[] APOS; }### Answer:
@Test public void testGetString() { Document doc = getXPathDocument(); assertEquals("attribval", XmlUtil.getString(doc, "/x/y/@attrib")); assertEquals("zval", XmlUtil.getString(doc, "/x/z/text()")); assertEquals("y", XmlUtil.getString(doc, "/x/*[1]/name()")); assertEquals("z", XmlUtil.getString(doc, "/x/*[2]/name()")); assertEquals("<x><y attrib=\"attribval\"/><z>zval</z></x>", XmlUtil.getString(doc, "/x")); }