Hello, i´m have to parse an XML-Data which describes a level for a game, i think i have problems with the namespace.
My code: Document doc = null; SAXReader reader = new SAXReader(); try{ doc = reader.read("Example_Level.xml"); }catch(DocumentException e){ System.err.println("Level-Datei konnte nicht gelesen werden"); } Node node = doc.selectSingleNode("/level/size/width"); if(doc != null){ Element element = (Element) node; String text = element.getText(); System.out.println("Width: " + text); } The line 'String text = element.getText();' throws a NullPointerException, i think because the Node is null. A part of the XML-File: <?xml version="1.0" encoding="UTF-8"?> <level xmlns="http://swt.informatik.uni-mannheim.de/2007/BomberManLevel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://swt.informatik.uni-mannheim.de/2007/BomberManLevel BombermanLevel.xsd "> <creator>Daniel Brenner</creator> <date>2007-03-20</date> <size> <width>16</width> <height>16</height> </size> ............. Does anyone see the mistake i make? Greetz Felix ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user