0

我正在尝试使用 Rome1.0 和 Java 访问播客附件中的 .mp3 链接。附件包含类型、url 和长度。我找不到任何文档。Java.net 上的 wiki 已被删除。

public static void main(String[] args) throws IOException, IllegalArgumentException,  FeedException 
{
    URL url = new URL("http://www.theskepticsguide.org/feed/rss.aspx? feed=SGU");
    XmlReader reader = null;

    /*try {

        reader = new XmlReader(url);
        SyndFeed feed = new SyndFeedInput().build(reader);
        System.out.println("Feed Title: " + feed.getAuthor());

        for (Iterator i = feed.getEntries().iterator(); i.hasNext();); 
        {
            SyndEntry entry = (SyndEntry) i.next();
            System.out.println("Title: " + entry.getTitle());
            System.out.println("Description: " +  entry.getDescription().getValue());
            System.out.println("Updated: " + entry.getPublishedDate());

//我希望做类似 System.out.println("Enclosure Url:" + entry.getEnclosures()) }

    } finally {
        if (reader != null)
            reader.close();

    }*/
4

1 回答 1

1

试试这个它对我有用

SyndEntry entry;

                for (int i = 0; i < feed.getEntries().size(); i++) {
                    entry = (SyndEntry) result.getEntries().get(i);
                    Log.e("Entry ", "===================================================================");

                    Log.e("Entry ", "Title          :  "+entry.getTitle());
                    Log.e("Entry ", "Link           :  "+entry.getLink());
                    Log.e("Entry ", "Uri            :  "+entry.getUri());
                    Log.e("Entry ", "Description    :  "+entry.getDescription().getValue());
                    SyndEnclosure enc = (SyndEnclosure) entry.getEnclosures().get(0);
                    Log.e("Entry ", "URL    :  "+enc.getUrl());
                    Log.e("Entry ", "Length    :  "+enc.getLength());
                    Log.e("Entry ", "Type    :  "+enc.getType());


                    Log.e("Entry ", "Pub Date       :  "+entry.getPublishedDate());
                    Log.e("Entry ", "===================================================================");
                }
于 2013-06-14T05:57:02.997 回答