How to read an attrbute of an XML tag?

Hi,

Can anybody comment onthe follwoing code what to add inorder to read an attribute of a tag?

*************************XML****************

<data-source type="org.apache.commons.dbcp.BasicDataSource" >

<set-property property="driverClassName" value="com.mysql.jdbc.Driver"/>

<set-property property="url" value="jdbc:mysql://localhost/cms"/>

<set-property property="username" value="root"/>

<set-property property="password" value="test"/>

<set-property property="maxActive" value="0"/>

<set-property property="maxWait" value="5000"/>

<set-property property="defaultAutoCommit" value="true"/>

<set-property property="defaultReadOnly" value="false"/>

</data-source>

*********************************************************

Java CODE:::::::::::::::::

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse (new java.io.File("some.xml");

doc.getDocumentElement ().normalize ();

System.out.println ("Root element of the doc is " +

doc.getDocumentElement().getNodeName());

NodeList listOfProperties = doc.getElementsByTagName("set-property");

Element sppty=(Element)listOfProperties;

System.out.println("ATTRIBUTE Property Value-->"+sppty.getAttribute("property"));

ABOVE CODE THROWS ME NULL POINTER EXCEPTION, pls correct me if am wrong?

BR,

Peace

[1601 byte] By [balajighantaa] at [2007-10-2 12:21:54]
# 1
Element sppty=(Element)listOfProperties; a NodeList is not an Elementuse NodeList.getLength()and NodeList.item(x)to retrieve individual nodes
dmbdmba at 2007-7-13 9:12:06 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...