List of utility methods to do XPath Get
String | getLatestVersion(String tempDir, String url, String groupId, String artifactId, String version) get Latest Version return getLatestVersion(tempDir, url, null, groupId, artifactId, version);
|
List | getListValue(Node node, XPathExpression expression) Evaluates the XPath expression in the specified context and returns the found items as a List. try { NodeList nodeList = (NodeList) expression.evaluate(node, XPathConstants.NODESET); List<String> list = new ArrayList<String>(nodeList.getLength()); for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); list.add(item.getFirstChild().getNodeValue()); return list; ... |
HashMap | getListValue(String targetDoc, List get List Value DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(targetDoc.getBytes(encoding))); XPathFactory pathFactory = XPathFactory.newInstance(); XPath xpath = pathFactory.newXPath(); XPathExpression pathExpression; String result; HashMap<String, String> values = new HashMap<String, String>(); for (String xpathExp : xpathExps) { ... |
String | getMessage(XPathExpressionException e) get Message String msg; Throwable t = e; do { msg = t.getMessage(); t = t.getCause(); } while (msg == null && t != null); return msg; |
String | GetMobivateSessionId() Get Mobivate Session Id try { String loginUri = String.format(LoginUrlModifier, URLEncoder.encode(Username, "ISO-8859-1"), Password); Document document = DoApiCall(loginUri, null); return extractData(document, "/xaresponse/session"); } catch (XPathExpressionException | UnsupportedEncodingException ex) { return null; |
String | getNameBasedXPath(Node n, boolean includeCurrent) get Name Based X Path Node parent = null; Stack<Node> hierarchy = new Stack<Node>(); if (includeCurrent) { hierarchy.push(n); parent = n.getParentNode(); while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { hierarchy.push(parent); ... |
XPath | getNewXPath() get New X Path return XPathFactory.newInstance().newXPath();
|
XPath | getNewXPath() Create and return a new XPath object from ThreadLocal . return XPATH_FACTORY.get().newXPath();
|
Node | getNode(Node node, XPathExpression xpath) get Node try { Object result = xpath.evaluate(node, XPathConstants.NODE); return (Node) result; } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath", e); |
Node | getNode(String xPathExpression, Node node) get Node return (Node) xPath.evaluate(xPathExpression, node, XPathConstants.NODE);
|