Example usage for javax.xml.xpath XPathExpressionException printStackTrace

List of usage examples for javax.xml.xpath XPathExpressionException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.xpath XPathExpressionException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Print stack trace to System.err .

Usage

From source file:Main.java

public static NodeList getValueAsNodes(String filePath, String value)
        throws ParserConfigurationException, SAXException, IOException {
    NodeList nodeList = null;//from   ww  w.  j  av a 2  s  .  com
    XPathFactory xpathFactory = XPathFactory.newInstance();
    XPath xpath = xpathFactory.newXPath();
    try {
        XPathExpression expr = xpath.compile(value);
        nodeList = (NodeList) expr.evaluate(getDoc(filePath), XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return nodeList;
}

From source file:Main.java

public static NodeList selectNodes(Node node, String express) {
    NodeList result = null;/*from   w  ww . j a  v a2 s.  co m*/
    XPathFactory xpathFactory = XPathFactory.newInstance();
    XPath xpath = xpathFactory.newXPath();
    try {
        result = (NodeList) xpath.evaluate(express, node, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return result;
}

From source file:Main.java

public static Node selectSingleNode(Node node, String express) {
    Node result = null;//from  w  ww . j a  v a2s  .com
    XPathFactory xpathFactory = XPathFactory.newInstance();
    XPath xpath = xpathFactory.newXPath();
    try {
        result = (Node) xpath.evaluate(express, node, XPathConstants.NODE);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return result;
}

From source file:Main.java

/**
 * Query xml result./* w w w .  j  av a2  s . co m*/
 * 
 * @param doc
 *            the doc
 * @param xpathExpression
 *            the xpath expression
 * @return the object
 */
public static NodeList queryXMLResult(Document doc, String xpathExpression) {
    // Document doc = getDocument(result);
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    NodeList XmlResult = null;
    try {
        XPathExpression expr = xpath.compile(xpathExpression);
        XmlResult = evaluateXpath(doc, expr);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return XmlResult;
}

From source file:Main.java

/**
 * convenience method to generate an XPathExpression object from a string representing an Xpath
 * @param pathstring the string/*from   ww  w.ja va  2  s .c  o  m*/
 * @return an Xpath object, or null if there was an exception
 */
public static XPathExpression makeXPathFromString(String pathstring) {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expr = null;
    try {
        expr = xpath.compile(pathstring);
    } catch (XPathExpressionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }
    return expr;
}

From source file:Main.java

public static Object executeXPath(Document document, String expression, QName outputType) {
    Object result = null;/*from   ww w .j  av a2s. c o m*/
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xpath = xPathfactory.newXPath();
    XPathExpression expr;
    try {
        expr = xpath.compile(expression);
        result = expr.evaluate(document, outputType);
    } catch (XPathExpressionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}

From source file:Main.java

public static Object evalXPathExpr(String pathExpr, Document xmlDocument, QName returnType) {
    XPathFactory xPathFactory = XPathFactory.newInstance();
    XPath xpathObj = xPathFactory.newXPath();
    XPathExpression expr;//from   w w  w  .  j av  a2s  .  c  om
    Object result = null;
    try {
        expr = xpathObj.compile(pathExpr);
        result = expr.evaluate(xmlDocument, returnType);
    } catch (XPathExpressionException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    return result;
}

From source file:Main.java

public static Node selectSingleNode(Node refNode, String expression) {
    XPath xPath = XPathFactory.newInstance().newXPath();
    Node outNode = null;/*w w w . ja va  2  s .c o  m*/
    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 selectSingleNode(Document refNode, String expression) {
    XPath xPath = XPathFactory.newInstance().newXPath();
    Node outNode = null;//  www . jav  a  2 s  .c  o  m
    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 NodeList SelectNodes(Document doc, String xmlpath) {
    NodeList nodes = null;/*from www  .  j  a  v  a2s. com*/
    Object result;
    try {
        XPathFactory xFactory = XPathFactory.newInstance();
        XPath xpath = xFactory.newXPath();

        XPathExpression expr;
        expr = xpath.compile(xmlpath);
        result = expr.evaluate(doc, XPathConstants.NODESET);
        nodes = (NodeList) result;
    } catch (XPathExpressionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return nodes;
}