• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getNodeValue() returing null WHY?

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run the code below based on the Xml document below I getting null returned when I call getNodeValue(). for example if the child node is host I was expecting getNodeValue to return ftp.gastin.com. I am printing the toString of the FtpServer object, which returns the following
hostName = null
loginId = null
password = null
Any help in getting this data out of this document would be great.

<servers>
<ftp-server>
<host>ftp.gastin.com</host>
<login-id>cgastin</login-id>
<password>XXXXX</password>
</ftp-server>
</servers>

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you want is the child of the host node, which is a Text node. host is an Element and the nodeValue() of an element is always null.
Very confusing, but there is a great chart in the JavaDocs for org.w3c.dom.Node that summarizes what the various kinds of nodes return as nodeValue().
Bill
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic