XML Parser With Java Code

Intrepid1

New Member
I want to populate a Drop Down list via an XML File.I have crated the XML File already and the code i have written firstly to read the xml file and just give me the items from the xml file is compiliing but giving me errors when i want to run the code later.\[code\]public ArrayList readXML(){ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); Document dom; dom = db.parse("PVS_XML.xml"); Element docEle = dom.getDocumentElement(); NodeList nl = docEle.getElementsByTagName("item"); System.out.println(((Node) nl).getNodeValue()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null;}\[/code\]Error Message:\[code\]java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl cannot be cast to org.w3c.dom.Nodeat de.sidion.pvsng.pages.InputPage.readXML(InputPage.java:222)at de.sidion.pvsng.pages.InputPage.init(InputPage.java:255)at de.sidion.pvsng.pages.InputPage.<init>(InputPage.java:183)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\[/code\]
 
Back
Top