XpathUtils { public static boolean isEmpty(Node node) { return (node == null); }  static XPath xpath(); static Document documentFrom(InputStream is); static Document documentFrom(String xml); static Document documentFrom(URL url); static Double asDouble(String expression, Node node); static Double asDouble(String expression, Node node, XPath xpath); static String asString(String expression, Node node); static String asString(String expression, Node node, XPath xpath); static Integer asInteger(String expression, Node node); static Integer asInteger(String expression, Node node, XPath xpath); static Boolean asBoolean(String expression, Node node); static Boolean asBoolean(String expression, Node node, XPath xpath); static Float asFloat(String expression, Node node); static Float asFloat(String expression, Node node, XPath xpath); static Long asLong(String expression, Node node); static Long asLong(String expression, Node node, XPath xpath); static Byte asByte(String expression, Node node); static Byte asByte(String expression, Node node, XPath xpath); static Date asDate(String expression, Node node); static Date asDate(String expression, Node node, XPath xpath); static ByteBuffer asByteBuffer(String expression, Node node); static ByteBuffer asByteBuffer(String expression, Node node, XPath xpath); static boolean isEmpty(Node node); static Node asNode(String nodeName, Node node); static Node asNode(String nodeName, Node node, XPath xpath); static int nodeLength(NodeList list);  }
@Test public void testIsEmpty() throws Exception { Document document = XpathUtils.documentFrom(DOCUMENT); XPath xpath = xpath(); Node emptyNode = asNode("Foo/Fake", document, xpath); Node realNode = asNode("Foo/Count", document, xpath); assertTrue(isEmpty(emptyNode)); assertFalse(isEmpty(realNode)); }