• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nevermind i figured it out
 
reply
    Bookmark Topic Watch Topic
  • New Topic