import java.io.IOException; import org.w3c.dom.*; import org.xml.sax.SAXException; import javax.xml.parsers.*; import javax.xml.xpath.*; public class XPath2{ public static void main(String[] args) throws Exception { Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("inimesed.xml"); System.out.println(XPathFactory.newInstance().newXPath().evaluate( "//inimesed/inimene[3]/eesnimi/text()", doc)); } } /* E:\jaagup\12\02\xml>java XPath2 Kalle */