   Java DOM, problem with whitespaces in xml files
  When I load an xml file using DOM, it causes exceptions if I put any spaces in the xml file.eg this doesn't work:<sellers><test>aa</test></sellers>where as this does:<sellers><test>aa</test></sellers>I've been looking through the javadocs, but I cannot find anything.Heres what I'm using:DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();    DocumentBuilder builder = factory.newDocumentBuilder();Document doc = builder.parse("AgentMSellers.xml");Node n = doc.getDocumentElement();System.out.println(n.getFirstChild().getFirstChild().getNodeValue());I've tried these which seem to do nothing:factory.setIgnoringElementContentWhitespace(true);n.normalize();doc.normalize();doc.normalizeDocument();Thanks.   
  I would guess that it is treating the whitespace as text.Thus<sometag>    <othertag>aa</othertag></sometag>would be treated as<sometag>youwanttoignorethistext<othertag>aa</othertag></sometag>What you probably want to do is to check if a node is text and if so, ignore it or deal with it. (You are probably getting an exception because you are trying to access a child node of the whitespace node (it doesn't have one).)Note: i could be wrong though. (I normally use a custom SAX Parser, not DOM)   