import java.io.IOException; import org.w3c.dom.*; import org.xml.sax.SAXException; import javax.xml.parsers.*; import javax.xml.xpath.*; public class XPath1{ public static void main(String[] args) throws Exception { Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("inimesed.xml"); NodeList s6lmed=(NodeList)(XPathFactory.newInstance().newXPath().evaluate( "//inimesed/inimene/eesnimi/text()", doc, XPathConstants.NODESET)); for (int i = 0; i < s6lmed.getLength(); i++) { System.out.println(s6lmed.item(i).getNodeValue()); } } } /* E:\jaagup\12\02\xml>java XPath1 Juku Juku Kalle Mari Oskar */