List of utility methods to do XPath Create
String | getXPath(Node n) Constructs a XPath query to the supplied node. if (null == n) return null; Node parent = null; Stack hierarchy = new Stack(); StringBuffer buffer = new StringBuffer(); hierarchy.push(n); parent = n.getParentNode(); while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { ... |
String | getXPath(Node n) Constructs a XPath query to the supplied node. if (null == n) return null; Node parent = null; Stack<Node> hierarchy = new Stack<Node>(); StringBuffer buffer = new StringBuffer(); hierarchy.push(n); parent = n.getParentNode(); while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { ... |
String | getXPath(Node n) Creates XPath expression for a given DOM node Preconditions.checkNotNull(n); Stack<Node> hierarchy = new Stack<Node>(); StringBuilder buffer = new StringBuilder(); hierarchy.push(n); Node parent = getParent(n); while (parent != null) { hierarchy.push(parent); if (parent.getNodeType() == Node.DOCUMENT_NODE) { ... |
String | getXPath(Node n) Constructs a XPath query to the supplied node. if (null == n) { throw new IllegalArgumentException("Invalid node"); ArrayList<Node> hierarchy = new ArrayList<Node>(); StringBuffer buffer = new StringBuffer(); Node parent = null; hierarchy.add(n); parent = n.getParentNode(); ... |
String | getXPath(Node node) get X Path Node parent = node.getParentNode(); if (parent == null) { return ""; return getXPath(parent) + "/" + node.getLocalName(); |
String | getXPath(Node node) get X Path if (null == node) return null; Node parent = null; Stack<Node> hierarchy = new Stack<Node>(); StringBuilder buffer = new StringBuilder(); hierarchy.push(node); parent = node.getParentNode(); while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { ... |
String | getXPath(Node node) Create a XPath expression denoting the node's absolute position. StringBuilder sb = new StringBuilder(); buildXPath(node, sb); return sb.toString(); |
String | getXPath(Node node, String xpath) get X Path String elementName = ""; if (node instanceof Element) { elementName = node.getNodeName(); int prev_siblings = 1; Node prev_sibling = node.getPreviousSibling(); while (null != prev_sibling) { if (prev_sibling.getNodeType() == node.getNodeType()) { if (prev_sibling.getNodeName().equalsIgnoreCase(node.getNodeName())) { ... |
XPathExpression | getXPath(String exp, NamespaceContext ctx) get X Path if (ctx == null) { return getXPath(exp); XPath mRetVal = sFactory.newXPath(); mRetVal.setNamespaceContext(ctx); return mRetVal.compile(exp); |
XPathExpression | getXPath(String expression) get X Path try { return getXPathFactory().newXPath().compile(expression); } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath Expression " + expression, e); |