當前位置: 首頁>>代碼示例>>Java>>正文


Java XPath.evaluateExpression方法代碼示例

本文整理匯總了Java中javax.xml.xpath.XPath.evaluateExpression方法的典型用法代碼示例。如果您正苦於以下問題:Java XPath.evaluateExpression方法的具體用法?Java XPath.evaluateExpression怎麽用?Java XPath.evaluateExpression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.xpath.XPath的用法示例。


在下文中一共展示了XPath.evaluateExpression方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test05

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test05(XPath xpath, Document doc) throws XPathExpressionException {
    double result1 = xpath.evaluateExpression("count(/Customers/Customer)", doc, Double.class);
    assertTrue(result1 == 3.0);
    int result2 = xpath.evaluateExpression("count(/Customers/Customer)", doc, Integer.class);
    assertTrue(result2 == 3);
    long result3 = xpath.evaluateExpression("count(/Customers/Customer)", doc, Long.class);
    assertTrue(result3 == 3);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:XPathAnyTypeTest.java

示例2: test08

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test08(XPath xpath, Document doc) throws XPathExpressionException {
    XPathNodes nodes = xpath.evaluateExpression("/Customers/Customer", doc, XPathNodes.class);
    assertTrue(nodes.size() == 3);
    for (Node n : nodes) {
        assertEquals(n.getLocalName(), "Customer");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:XPathAnyTypeTest.java

示例3: test01

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "xpath", expectedExceptions = NullPointerException.class)
public void test01(XPath xpath) throws XPathExpressionException {
    double result = xpath.evaluateExpression(null, (Object) null, Double.class);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:XPathAnyTypeTest.java

示例4: test02

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "xpath", expectedExceptions = NullPointerException.class)
public void test02(XPath xpath) throws XPathExpressionException {
    double result = xpath.evaluateExpression("1+1", (Object) null, null);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:XPathAnyTypeTest.java

示例5: test03

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "xpath")
public void test03(XPath xpath) throws XPathExpressionException {
    int result = xpath.evaluateExpression("1+1", (Object) null, Integer.class);
    assertTrue(result == 2);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例6: test04

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test04(XPath xpath, Document doc) throws XPathExpressionException {
    boolean result1 = xpath.evaluateExpression("boolean(/Customers/Customer[@id=3])", doc, Boolean.class);
    assertTrue(result1);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例7: test06

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "invalidNumericTypes", expectedExceptions = IllegalArgumentException.class)
public void test06(XPath xpath, Class<Number> type) throws XPathExpressionException {
    xpath.evaluateExpression("1+1", (Object) null, type);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:XPathAnyTypeTest.java

示例8: test07

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test07(XPath xpath, Document doc) throws XPathExpressionException {
    String result1 = xpath.evaluateExpression("string(/Customers/Customer[@id=3]/Phone/text())", doc, String.class);
    assertTrue(result1.equals("3333333333"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例9: test09

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test09(XPath xpath, Document doc) throws XPathExpressionException {
    Node n = xpath.evaluateExpression("/Customers/Customer[@id=3]", doc, Node.class);
    assertEquals(n.getLocalName(), "Customer");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例10: test10

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document", expectedExceptions = IllegalArgumentException.class)
public void test10(XPath xpath, Document doc) throws XPathExpressionException {
    File n = xpath.evaluateExpression("/Customers/Customer[@id=3]", doc, File.class);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:XPathAnyTypeTest.java

示例11: test11

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test11(XPath xpath, Document doc) throws XPathExpressionException {
    XPathEvaluationResult<?> result = xpath.evaluateExpression("boolean(/Customers/Customer[@id=3])", doc);
    verifyResult(result, true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例12: test12

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test12(XPath xpath, Document doc) throws XPathExpressionException {
    XPathEvaluationResult<?> result = xpath.evaluateExpression("count(/Customers/Customer)", doc);
    verifyResult(result, 3.0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例13: test13

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test13(XPath xpath, Document doc) throws XPathExpressionException {
    XPathEvaluationResult<?> result = xpath.evaluateExpression(
            "string(/Customers/Customer[@id=3]/Phone/text())", doc, XPathEvaluationResult.class);
    verifyResult(result, "3333333333");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:XPathAnyTypeTest.java

示例14: test14

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test14(XPath xpath, Document doc) throws XPathExpressionException {
    XPathEvaluationResult<?> result = xpath.evaluateExpression("/Customers/Customer", doc);
    verifyResult(result, "Customer");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java

示例15: test15

import javax.xml.xpath.XPath; //導入方法依賴的package包/類
@Test(dataProvider = "document")
public void test15(XPath xpath, Document doc) throws XPathExpressionException {
    XPathEvaluationResult<?> result = xpath.evaluateExpression("/Customers/Customer[@id=3]", doc);
    verifyResult(result, "Customer");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:XPathAnyTypeTest.java


注:本文中的javax.xml.xpath.XPath.evaluateExpression方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。