This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Can some one help I keep getting a d**m null value and no examples work
 
jQuery in Action, 3rd edition