Not able to read XML file

janilol

New Member
When I am trying to read xml file from my Java code, I getting error as shown in attached image.
dgt2g.jpg
Java code : \[code\]public ActionForward xmlupload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String target = new String("success"); System.out.println("I AM IN ACTION"); List<XmltodbBO> branchList = new ArrayList<XmltodbBO>(); try { File file = new File("D:\\FNDWRR.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(file); doc.getDocumentElement().normalize(); System.out.println("Root element " + doc.getDocumentElement().getNodeName()); NodeList nodeLst = doc.getElementsByTagName("fsg:RptLine"); System.out.println("Root Tag value"); XmltodbDAO sim=new XmltodbDAO(); for (int s = 0; s < nodeLst.getLength(); s++) { XmltodbBO bO=new XmltodbBO(); Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("fsg:RptCell"); System.out.print(fstNmElmntLst.getLength()); Node current = fstNmElmntLst.item(0); if(current.getNodeType() == Node.ELEMENT_NODE){ String nodeName = current.getNodeName(); Element fstNmElmnt = (Element) fstNmElmntLst.item(0); NodeList fstNm = fstNmElmnt.getChildNodes(); Text itemCheckedText = (Text) fstNm.item(0); if (itemCheckedText != null) { System.out.println("Tag value : " + ((Node) fstNm.item(0)).getNodeValue()); bO.setFirstfieldName( fstNm.item(0).getNodeValue()); } } if( fstNmElmntLst.getLength()>1){ Node current1 = fstNmElmntLst.item(1); if(current1.getNodeType() == Node.ELEMENT_NODE){ Element fstNmElmnt = (Element) fstNmElmntLst.item(1); NodeList fstNm = fstNmElmnt.getChildNodes(); Text itemCheckedText1 = (Text) fstNm.item(0); if (itemCheckedText1 != null) { System.out.println("Tag value : " + ((Node) fstNm.item(0)).getNodeValue()); bO.setSecondfieldName( fstNm.item(0).getNodeValue()); } } } if( fstNmElmntLst.getLength()>2){ Node current1 = fstNmElmntLst.item(2); if(current1.getNodeType() == Node.ELEMENT_NODE){ Element fstNmElmnt = (Element) fstNmElmntLst.item(2); NodeList fstNm = fstNmElmnt.getChildNodes(); Text itemCheckedText1 = (Text) fstNm.item(0); if (itemCheckedText1 != null) { System.out.println("Tag value : " + ((Node) fstNm.item(0)).getNodeValue()); bO.setThirdfieldName(fstNm.item(0).getNodeValue()); } } } } branchList.add( bO); } sim.adddb(branchList); }catch (Exception e) { e.printStackTrace(); } return (mapping.findForward(target)); }\[/code\]When I am running the same application using main class, it is working fine. But when I am trying to do the same using struts action, I am getting this error. Please help me out.
 
Back
Top