Với phiên bản mới nhất của các chi tiết kỹ thuật cho Java servlet và Enterprise Java Beans, Sun đã chuyển sang một định dạng XML thông tin cấu hình của nó. Ở đây chúng ta chỉ đơn giản nó là như thế nào để làm như vậy cho các chương trình của chúng ta bằng cách sử dụng XPath. | LINE I told him of your stealth unto this wood. LINE If we turn our new utility loose on our file to find all attributes in the file java XPathGrep @ XPathGrep will produce time Sun Apr 16 2 42am ET - . Markets Closed. Ticker ORCL Price Ticker GE Price Ticker MSFT Price Ticker IBM Price Ticker T Price Ticker LU Price Ticker CSCO Price Besides being simple to implement you ll find XPathGrep a handy sidekick in your daily work with XML. Using XPath for Reading Configuration Files With the latest releases of the specifications for Java servlets and Enterprise Java Beans Sun has moved to an all-XML format for its configuration information. Here we show how simple it is to do the same for our own programs using XPath. Let s say we have the following file which stores named database connections and the appropriate connection information for each -- -- connections connection name default username xmlbook username password xmlbook password dburl jdbc oracle thin @localhost 1521 ORCL dburl connection connection name demo username scott username password tiger password dburl jdbc oracle thin @ 1521 xml dburl connection connection name test username test username password test password dburl jdbc oracle thin @linuxbox 1721 ORCL dburl connection connections We can create a ConnectionFactory class that reads the file as a resource from the CLASSPATH and returns a JDBC connection for the connection name passed in. Example shows the implementation which leverages the following methods selectSingleNode To find the named connection in the XML-based configuration file valueOf On the connection element we find to quickly grab the values of the interesting child elements containing the JDBC connection information Example . Using an XML File for Configuration Information import . import .