import oracle.xml.parser.v2.*; import org.w3c.dom.NodeList; public class TestTimegram{ static XMLDocument theTimegram = null; public static void main(String arg[]) throws Exception { // Construct a parser DOMParser dp = new DOMParser(); // Parse the XML document returned by CurrentDateXML.jsp dp.parse("http://xmlapps/ch07/CurrentDateXML.jsp"); // Get the XML Document theTimegram = dp.getDocument(); // Use XPath expression /timegram/time to fetch the time System.out.println("Current time: " + theTimegram.valueOf("/timegram/time")); // Use XPath expression /timegram/sponsor/name to fetch the time System.out.println(" Courtesy of: " + theTimegram.valueOf("/timegram/sponsor/name")); } } |