• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Node Value Question

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
New to XML, trying to learn to get data out of XML file. File reads like
[CODE]
- <chart-config>
- <chart>
<dataflow>Row</dataflow>
<starting-col>2</starting-col>
<starting-row>25</starting-row>
<chart-name>lineChart</chart-name>
</chart>
</chart-config>
[CODE]
Trying to figure out how to pull the values of the XML file out. I am trying to use DOM, but NodeValue always comes out null.
 
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
The JavaDocs for org.w3c.dom.Node have a marvelous table sumarizing what you get from getNodeName and getNodeValue for various subclasses of Node.
The key thing you need to realize is that in XML like this:
<dataflow>Row</dataflow>
You have an Element Node named dataflow that contains a Text Node which has the value "Row". The result of getNodeValue() on the Element Node is null.
You have to get the child node to get the Text Node.
Bill
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic