Demos and Usage of javax.xml.xpath.XPathExpression.evaluate(Object item,QName returnType)


   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathExpressionException;
   4:         ...
   5: 
   6:     private XPathExpression expression;
   7: 
   8:         ...
   9:         resolver.addVariable(null, "date", formattedDate);
  10:         return (Element) expression.evaluate(document, XPathConstants.NODE);
  11:     }

View Full Code Here
   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathExpressionException;
   4:         ...
   5: 
   6:     private XPathExpression expression;
   7: 
   8:         ...
   9:             resolver.addVariable(null, "date", formattedDate);
  10:             return (Element) expression.evaluate(document, XPathConstants.NODE);
  11:     }

View Full Code Here
   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathFactory;
   4:         ...
   5:                     try {
   6:                         NodeList nodes = (NodeList)exp.evaluate(dom, XPathConstants.NODESET);
   7:                         for (int i=0; i<nodes.getLength(); i++) {
   8:                             System.out.println(nodes.item(i).getTextContent());
   9:                         }

View Full Code Here
   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathFactory;
   4:         ...
   5:                     try {
   6:                         NodeList nodes = (NodeList)exp.evaluate(dom, XPathConstants.NODESET);
   7:                         for (int i=0; i<nodes.getLength(); i++) {
   8:                             System.out.println(nodes.item(i).getTextContent());
   9:                         }

View Full Code Here
   1: import javax.xml.xpath.XPath;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathExpressionException;
   4:         ...
   5: 
   6:   public XPathExpression compile(String expression)
   7:     throws XPathExpressionException
   8:         ...
   9:   {
  10:     XPathExpression expr = compile(expression);
  11:         ...
  12:     return expr.evaluate(item, returnType);

View Full Code Here
   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathExpressionException;
   4:         ...
   5:     
   6:     public static SimpleNodeList getElements(XPathExpression expression, Node node) throws XPathExpressionException {
   7:         ...
   8:         return new SimpleNodeList((NodeList)expression.evaluate(node, XPathConstants.NODESET));
   9:     }
  10:         ...
  11: 
  12:     public static Node getElement(XPathExpression expression, Node node) throws XPathExpressionException {

View Full Code Here
   1: import javax.xml.xpath.XPathConstants;
   2: import javax.xml.xpath.XPathExpression;
   3: import javax.xml.xpath.XPathFactory;
   4:         ...
   5:             for (int i = 0; i < schemaNodes.length; ++i) {
   6:                 XPathExpression xpathSchema = xpath.compile((String)schemas.elementAt(i));
   7:         ...
   8:                 schemaNodes[i] = (NodeList) xpathSchema.evaluate(doc, XPathConstants.NODESET);
   9:             }
  10:         ...
  11:             for (int i = 0; i < instanceNodes.length; ++i) {
  12:                 XPathExpression xpathInstance = xpath.compile((String)instances.elementAt(i));

View Full Code Here