Unbekannter Fehler bei XML

Moin, ich habe heute angefangen mit Java und XML, in Net kann ich es Schon aber in Java haperts noch. Ich möchte einfach die Unterknoten des DocumentElement Auslesen.

try {					
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			
			InputStream instream = UpdateVZPath.openStream();
			
			Document Document = builder.parse(instream);
			
			Element root = (Element) Document.getDocumentElement();
			NodeList nlist = root.getChildNodes();
			
			
			System.out.println("Anzahl der Datensätze: " + root.getChildNodes().getLength());
			System.out.println("Publisher: " + root.getAttribute("Publisher"));
			System.out.println("Fehler Mail Adresse: " + root.getAttribute("Adresse"));
			System.out.println("Gefundene Software: " + nlist.getLength());
		
			
			for(int i = 0 ; i < nlist.getLength() ; i++ ){
				
				Element selnode = (Element) nlist.item(i);
				System.out.println(selnode.getAttribute("SoftwareName"));
				
			}
			
			
			
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

und der Fehler:

Anzahl der Datensätze: 5
Publisher: Software Lösungen Wagner
Fehler Mail Adresse: wagnerandreas17@freemail.de
Gefundene Software: 5
Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element
at Main.checkForUpdates(Main.java:44)
at UpdateStart$2.actionPerformed(UpdateStart.java:58)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Einige dieser Knoten sind eben kein “Element”. Das kann manchmal ziemlich absurd wirkende Ursachen haben (z.B. ein Leerzeichen, wo keins sein sollte). Eine Möglichkeit ist es, sich das XML mal ganz scharf anzuschauen … hoppala, dafür bräuchte man das XML ja… und ggf. auch ein KSKB… naja, die andere ist, sowas wie

Node node = nlist.item(i);
if (node instanceof Element)
{
    Element selnode = (Element)node;
...
}