1 7 8 package org.dom4j.xpath; 9 10 import junit.textui.TestRunner; 11 12 import org.dom4j.AbstractTestCase; 13 import org.dom4j.Node; 14 import org.dom4j.XPath; 15 16 22 public class ObjectTest extends AbstractTestCase { 23 protected static String [] paths = {"name(/.)", "name()"}; 24 25 public static void main(String [] args) { 26 TestRunner.run(ObjectTest.class); 27 } 28 29 public void testXPaths() throws Exception { 32 Node element = document.selectSingleNode("//author"); 33 int size = paths.length; 34 35 for (int i = 0; i < size; i++) { 36 testXPath(document, paths[i]); 37 testXPath(element, paths[i]); 38 } 39 } 40 41 protected void testXPath(Node node, String xpathText) { 44 XPath xpath = node.createXPath(xpathText); 45 Object object = xpath.evaluate(node); 46 } 47 } 48 49 85 | Popular Tags |