<%@ page language="java" import="javax.xml.parsers.*,org.w3c.dom.*,org.apache.xpath.*" %> <% DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse("C:/cat.xml"); NodeList cats = XPathAPI.selectNodeList(doc, "//page/categories/category/text()"); for(int i = 0; i < cats.getLength(); i++) { String txt = cats.item(i).getNodeValue(); out.println(txt); } %>