List of usage examples for javax.xml.xpath XPathConstants NODE
QName NODE
To view the source code for javax.xml.xpath XPathConstants NODE.
Click Source Link
The XPath 1.0 NodeSet data type.
From source file:Main.java
public static Node readNodeValFromXmlDocument(Document xmlDocument, String xpathQueryExpression, XPath xpathInstance) throws XPathExpressionException { return (Node) xpathInstance.compile(xpathQueryExpression).evaluate(xmlDocument, XPathConstants.NODE); }
From source file:Main.java
public static Element SelectSingleElement(Element parent, String expression) { Element element = null;// w w w. j a va 2 s. co m XPath xpath = getXPath(); try { XPathExpression xpathExpression = xpath.compile(expression); element = (Element) xpathExpression.evaluate(parent, XPathConstants.NODE); } catch (Exception e) { throw new RuntimeException(e); } return element; }
From source file:Main.java
/** * @param doc//from ww w . j a v a 2s. c o m * @param expr * @return * @throws XPathExpressionException */ public static Element findElement(Document doc, XPathExpression expr) throws XPathExpressionException { Object evaluate = expr.evaluate(doc, XPathConstants.NODE); return (Element) evaluate; }
From source file:Main.java
public static Node evaluateToNode(Document document, String expression) throws XPathExpressionException { return (Node) evaluate(document, expression, XPathConstants.NODE); }
From source file:Main.java
public static Node selectSingleNode(Document xmlDocument, String expression) throws XPathExpressionException { return (Node) selectObject(xmlDocument, expression, XPathConstants.NODE); }
From source file:Main.java
public static Node getNode(Node node, String expression) throws XPathExpressionException { XPathExpression expr = xpath.compile(expression); Node r = (Node) expr.evaluate(node, XPathConstants.NODE); return r;/*from w w w . j a va2 s . c o m*/ }
From source file:Main.java
public static Node selectSingleNode(Node refNode, String expression) { XPath xPath = XPathFactory.newInstance().newXPath(); Node outNode = null;/*from w w w .ja v a 2s . c om*/ try { outNode = (Node) xPath.compile(expression).evaluate(refNode, XPathConstants.NODE); } catch (XPathExpressionException e) { // TODO Auto-generated catch block e.printStackTrace(); } return outNode; }
From source file:Main.java
public static Node findSchemaPropertyByDimensionName(Document xmlDoc, String xPathExpression) { XPath xPath = XPathFactory.newInstance().newXPath(); Node nOde = null;/* w ww. ja va 2s. c om*/ try { nOde = (Node) xPath.compile(xPathExpression).evaluate(xmlDoc, XPathConstants.NODE); } catch (XPathExpressionException e) { e.printStackTrace(); } return nOde; }
From source file:Main.java
public static synchronized boolean deleteNode(String charCode, Node root) { try {//from w ww . j a v a 2s. c o m XPath xpath = XPathFactory.newInstance().newXPath(); Node node = (Node) xpath.evaluate(String.format(XPATH_EVAL_ID, charCode), root, XPathConstants.NODE); if (node != null) { // remove existing node Node parent = node.getParentNode(); parent.removeChild(node); return true; } } catch (XPathExpressionException e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static Element getElementByXPath(Element e, String xPathExpression) throws XPathExpressionException { XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); return (Element) (xPath.evaluate(xPathExpression, e, XPathConstants.NODE)); }