import java.io.File;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
public class Test {
public static void main(String[] args) throws DocumentException {
SAXReader reader = new SAXReader();
Document doc = reader.read(new File("F:/a.xml"));
List<Node> nodes1 = doc.selectNodes("//ref/syn");
List<Node> nodes2 = doc.selectNodes("//ref/rel");
for (Node node : nodes1) {
System.out.println(node.selectSingleNode("word").getText() + " "
+ node.selectSingleNode("exp").getText());
}
for (Node node : nodes2) {
System.out.println(node.selectSingleNode("word").getText() + " "
+ node.selectSingleNode("exp").getText());
}
}
}