java - RSS Feed Parsing, extracting field value -


i totally new in rss feed parsing. trying, duration of mp3 file. unable value specific tag

<itunes:duration>01:00:00</itunes:duration> 

here parsing code:

public list<rssitem> parse() {     final rssitem currentmessage = new rssitem();     rootelement root = new rootelement("rss");     final list<rssitem> messages = new arraylist<rssitem>();      element channel = root.getchild("channel");     element item = channel.getchild(item);     item.setendelementlistener(new endelementlistener() {         public void end() {             messages.add(currentmessage.copy());         }     });     item.getchild(title).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.settitle(body);                 }             });     item.getchild(link).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setlink(body);                 }             });     item.getchild(description).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setdescription(body);                 }             });     item.getchild("http://purl.org/rss/1.0/modules/content/", "encoded")             .setendtextelementlistener(new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setcontent(body);                 }             });     item.getchild(content).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setcontent(body);                 }             });     item.getchild(pub_date).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setdate(body);                 }             });     item.getchild(category).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setcategory(body);                 }             });     element enclosure = item.getchild(enclosure);     enclosure.setstartelementlistener(new startelementlistener() {          public void start(attributes attributes) {             currentmessage.setadiourl(attributes.getvalue("url"));             // currentmessage.setadiofileduration(attributes.getvalue("length"));         }      });     item.getchild(adiofileduration).setendtextelementlistener(             new endtextelementlistener() {                 public void end(string body) {                     currentmessage.setadiofileduration(body);                 }             }); //adiofileduration=itunes      try {         xml.parse(this.getinputstream(), xml.encoding.utf_8,                 root.getcontenthandler());     } catch (exception e) {         throw new runtimeexception(e);     }     return messages; } 

and here rss object:

 <item>  <title>fantasyguru.com show - jul 30,2009</title>  <link>http://www.blogtalkradio.com/fantasyguru/2009/07/30/fantasygurucom-show</link> ..... .... .... .... <itunes:duration>01:00:00</itunes:duration>  <media:group>   <media:content url="http://www.blogtalkradio.com/fantasyguru/2009/07/30/fantasygurucom-show.mp3" filesize="14426407" type="audio/mpeg" /><media:content url="http://www.blogtalkradio.com/fantasyguru/2009/07/30/fantasygurucom-show.wma" filesize="14426407" type="audio/x-ms-wma" />  </media:group>  <itunes:author>fantasyguru</itunes:author>  <itunes:explicit>no</itunes:explicit>  <itunes:keywords>fantasy,nfl,sports,fantasyguru,football,blogtalkradio, blog talk radio</itunes:keywords>  <itunes:subtitle>fantasyguru.com show</itunes:subtitle> </item> 

http://docs.oracle.com/javase/tutorial/jaxb/intro/index.html

have had @ jaxb? it's nicer way parse through xml , might solve problem.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -