/** * Queries a {@link sirius.kernel.commons.Value} by evaluating the given xpath. * * @param path the xpath used to retrieve property * @return a Value wrapping the value returned by the given xpath expression * @throws java.lang.IllegalArgumentException if an invalid xpath was given */ @Nonnull public Value queryValue(String path) { return Value.of(queryString(path)); }
/** * Checks whether a node or non-empty content is reachable via the given * XPath. * * @param path the xpath to be checked * @return <tt>true</tt> if a node or non empty property was found, <tt>false</tt> otherwise * @throws IllegalArgumentException if an invalid xpath was given */ public boolean isFilled(String path) { return Strings.isFilled(queryString(path)); }
/** * Checks whether a node is not reachable or has empty content via the given * XPath. * * @param path the xpath to be checked * @return <tt>true</tt> if no node or a empty property was found, <tt>false</tt> otherwise * @throws IllegalArgumentException if an invalid xpath was given */ public boolean isEmpty(String path) { return Strings.isEmpty(queryString(path)); }
XMLReader r = new XMLReader(); r.addHandler("node", new NodeHandler() { @Override public void process(StructuredNode node) { System.out.println(node.queryString("name")); System.out.println(node.queryValue("price").asDouble(0d)); } }); r.parse(new FileInputStream("src/examples/test.xml"));