Hi, i´m checking if doc is null, because of the try-block, if the file is not read i don´t need the code in the the if-clause. but you´re right, this is not the problem.
sorry for my english, it is not good enough. greetings Meltsner, Kenneth schrieb: > > Not sure why you're checking whether doc is null after you run the > selectSingleNode(), but that's not your problem... > > -----Original Message----- > From: [EMAIL PROTECTED] > <[EMAIL PROTECTED]> > To: [email protected] <[email protected]> > Sent: Sat Apr 07 06:23:36 2007 > Subject: [dom4j-user] Problem with Namespace? > > 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 > <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > _______________________________________________ > dom4j-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/dom4j-user
