File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Can some one help I keep getting a d**m null value and no examples work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Can some one help I keep getting a d**m null value and no examples work" Watch "Can some one help I keep getting a d**m null value and no examples work" New topic
Author

Can some one help I keep getting a d**m null value and no examples work

Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
Document document = parser.getDocument();
Element RootElement = document.getDocumentElement();
NodeList Children = RootElement.getChildNodes();


NodeList ndeList = Children;
NodeList ndeMenuList;
NodeList ndeMenuItemList;
for(int i=0; i<ndeList.getLength();i++) {
if ( ndeList.item(i).getNodeType() == Node.ELEMENT_NODE ) {
String text = "";
//if ( ndeList.item(i).getNodeType() == Node.TEXT_NODE )
System.out.println(ndeList.item(i).getNodeName() + " = " + ndeList.item(i).getFirstChild().getNodeValue());

if ( ndeList.item(i).hasChildNodes() ) {
ndeMenuList = ndeList.item(i).getChildNodes();
for( int j=0; j < ndeMenuList.getLength(); j++ ) {
if ( ndeMenuList.item(j).getNodeType() == Node.ELEMENT_NODE ) {
System.out.println("\t" + ndeMenuList.item(j).getNodeName() + " = " + ndeMenuList.item(j).getFirstChild().getNodeValue() );
if ( ndeMenuList.item(j).getNodeType() == Node.ELEMENT_NODE ) {
ndeMenuItemList = ndeMenuList.item(j).getChildNodes();
for(int k=0; k<ndeMenuItemList.getLength();k++) {
System.out.println("\t\t" + ndeMenuItemList.item(k).getNodeName() + " = " + ndeMenuItemList.item(k).getNodeValue() );
}
}
}

}

}
}
}
I have this code and every time I do getNodeValue it returns null value when it prints
the examples say use getFirstChild() but it doesnt have a childNode
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
nevermind i figured it out
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can some one help I keep getting a d**m null value and no examples work