Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XML Parsing.  RSS feed

 
Richard Murray
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to parse the following XML and extract the PlaylistKey values and the TrackCount values



My code is as follows



The code manages to grab the PlaylistKey values easily enough but no matter what I do, I can't seem to get the TrackCount value.

Any help?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The code you have is trying to access an attribute of the TrackCount element called "TrackCount". You need the content of the element TrackCount, which is initself a child element of TrackCount.
[ February 13, 2007: Message edited by: Paul Sturrock ]
 
Richard Murray
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now using

Node tC = (Node) tc.item(i).getChildNodes();

However, I am now getting Null values when I try to print out
 
Richard Murray
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the code I have no, it's not getting me what I want though, any ideas?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You are still looking for an attribute not an element. Your code needs to get the node value of the child node of TrackCount (since the text between the element start and end is a child node in itself.
 
Richard Murray
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brain fart there, you're dead right, got it working now with the help of a great tutorial I found here http://www.developerfusion.co.uk/show/2064/
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!