Ask for read xml simple sample...

Now I have a xml file like this

--

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>

<servlet-name>

gen_daily

</servlet-name>

<servlet-class>

gen_daily

</servlet-class>

<init-param>

<param-name>clarent_init_dir</param-name>

<param-value>/mnt/VISL/stats/stats/clarent2</param-value>

</init-param>

<init-param>

<param-name>linefeed_mode</param-name>

<param-value>2</param-value>

</init-param>

</servlet>

<servlet>

<servlet-name>

RequestParamExample

</servlet-name>

<servlet-class>

RequestParamExample

</servlet-class>

</servlet>

<servlet>

<servlet-name>

RequestParamExample2

</servlet-name>

<servlet-class>

RequestParamExample2

</servlet-class>

</servlet>

<!-- Define example application events listeners -->

<!-- Define servlets that are included in the example application -->

<welcome-file-list>

<welcome-file>index.html</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<taglib>

<taglib-uri>

http://java.apache.org/tomcat/examples-taglib

</taglib-uri>

<taglib-location>

/WEB-INF/jsp/example-taglib.tld

</taglib-location>

</taglib>

<resource-ref>

<res-ref-name>mail/session</res-ref-name>

<res-type>javax.mail.Session</res-type>

<res-auth>Container</res-auth>

</resource-ref>

<security-constraint>

<display-name>Example Security Constraint</display-name>

<web-resource-collection>

<web-resource-name>Protected Area</web-resource-name>

<!-- Define the context-relative URL(s) to be protected -->

<url-pattern>/jsp/security/protected/*</url-pattern>

<!-- If you list http methods, only those methods are protected -->

<http-method>DELETE</http-method>

<http-method>GET</http-method>

<http-method>POST</http-method>

<http-method>PUT</http-method>

</web-resource-collection>

<auth-constraint>

<!-- Anyone with one of the listed roles may access this area -->

<role-name>tomcat</role-name>

<role-name>role1</role-name>

</auth-constraint>

</security-constraint>

</web-app>

--

now I want to get variable

<param-name>clarent_init_dir</param-name>

<param-value>/mnt/VISL/stats/stats/clarent2</param-value>

</init-param>

Any one can give me very sample program to do this?

I just need to read /mnt/VISL/stats/stats/clarent2 into a string

Calvin

[3445 byte] By [calvinchoi] at [2007-9-26 3:12:06]
# 1
which API u use for parsing XML document.Read this API doc .
SArshad at 2007-6-29 11:20:12 > top of Java-index,Archived Forums,Java Programming...