getNodeName() operation on an XML node returns #text

dishprili

New Member
\[code\]<person><firstname><lastname><salary></person>\[/code\]This is the XML I am parsing. When I try printing the node names of child elements of person, I gettextfirstnametextlastnametextsalaryHow do I eliminate #text being generated?Update -Here is my code\[code\]try { NodeList nl = null; int l, i = 0; File fXmlFile = new File("file.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); dbFactory.setValidating(false); dbFactory.setIgnoringElementContentWhitespace(true); dbFactory.setNamespaceAware(true); dbFactory.setIgnoringComments(true); dbFactory.setCoalescing(true); InputStream in; in = new FileInputStream(fXmlFile); Document doc = dBuilder.parse(in); doc.getDocumentElement().normalize(); Node n = doc.getDocumentElement(); System.out.println(dbFactory.isIgnoringElementContentWhitespace()); System.out.println(n); if (n != null && n.hasChildNodes()) { nl = n.getChildNodes(); for (i = 0; i < nl.getLength(); i++) { System.out.println(nl.item(i).getNodeName()); } }} catch (Exception e) { e.printStackTrace();}\[/code\]
 
Back
Top