解析<;外壳>;使用Java标记

解析<;外壳>;使用Java标记,java,android,xml,parsing,Java,Android,Xml,Parsing,我想解析这行rss提要 所以我可以在ImageView中使用它 我已经编写了一个完整的类来解析&tags,但是我无法以某种方式使用这个类,因为enclosure标记不在关闭,而是继续使用 这是我写的课 public class RSSReader { //Lists to store headlines, descriptions & images String url = "http://www.nu.nl/rss/Algemeen"; List<Str

我想解析这行rss提要

所以我可以在ImageView中使用它

我已经编写了一个完整的类来解析&tags,但是我无法以某种方式使用这个类,因为enclosure标记不在关闭,而是继续使用

这是我写的课

public class RSSReader {
    //Lists to store headlines, descriptions & images
    String url = "http://www.nu.nl/rss/Algemeen";
    List<String> titleList;
    List<String> descriptionList;
    List<String> imageList;
    public RSSReader() throws IOException{
        titleList = readRSS(url, "<title>");
        descriptionList= listFilter(readRSS(url, "<description>"), "&amp;nbsp;", "");
        imageList = readRSS(url, "<enclosure>");
    }
    public List<String> readRSS(String feedUrl, String tag) throws IOException, MalformedURLException {
        URL url = new URL(feedUrl);
        BufferedReader reader= new BufferedReader(new InputStreamReader(url.openStream()));
        String closingTag = new StringBuilder(tag).insert(1, "/").toString();
        String currentLine;
        List<String> tempList = new ArrayList<String>();
        while((currentLine = reader.readLine()) != null){
            Integer tagEndIndex = 0;
            Integer tagStartIndex = 0;
            while (tagStartIndex >= 0){
                tagStartIndex = currentLine.indexOf(tag, tagEndIndex);
                if(tagStartIndex >= 0){
                    tagEndIndex = currentLine.indexOf(closingTag, tagStartIndex);
                    tempList.add(currentLine.substring(tagStartIndex + tag.length(), tagEndIndex) + "\n");
                }
            }
        }
        tempList.remove(0);
        return tempList;
    }

    public List<String> getDesciptionList(){
        return descriptionList;
    }

    public List<String> getTitleList(){
        return titleList;
    }
    public List<String> getImageList(){
        return imageList;
    }

    public List<String> listFilter(List<String> tempList, String require, String replace){
        //Creates new List
        List<String> newList = new ArrayList<>();
        //Loops through old list and checks for the 'require' variable
        for(int i = 0; i < tempList.size(); i++){
            if(tempList.get(i).contains(require)){
                newList.add(tempList.get(i).replace(require, replace));
            }
            else{
                newList.add(tempList.get(i));
            }
        }
        return newList;
    }
}
公共类RSSReader{
//用于存储标题、说明和图像的列表
字符串url=”http://www.nu.nl/rss/Algemeen";
列表标题列表;
列表描述列表;
列表图像列表;
public RSSReader()引发IOException{
titleList=readRSS(url,“”);
descriptionList=listFilter(readRSS(url,“”,“,”);
imageList=readRSS(url,“”);
}
公共列表readRSS(stringfeedurl,stringtag)抛出IOException、MalformedUrlexException{
URL=新URL(feedUrl);
BufferedReader=新的BufferedReader(新的InputStreamReader(url.openStream());
String closingTag=new StringBuilder(tag).insert(1,“/”).toString();
串电流线;
List templast=new ArrayList();
while((currentLine=reader.readLine())!=null){
整数tagEndIndex=0;
整数tagStartIndex=0;
而(tagStartIndex>=0){
tagStartIndex=currentLine.indexOf(标记,tagEndIndex);
如果(tagStartIndex>=0){
tagEndIndex=currentLine.indexOf(closingTag,tagStartIndex);
add(currentLine.substring(tagStartIndex+tag.length(),tagEndIndex)+“\n”);
}
}
}
圣殿骑士。移除(0);
返回圣殿骑士;
}
公共列表GetDescriptionList(){
返回描述列表;
}
公共列表getTitleList(){
返回标题列表;
}
公共列表getImageList(){
返回图像列表;
}
公共列表listFilter(列表模板、字符串要求、字符串替换){
//创建新列表
List newList=newarraylist();
//循环浏览旧列表并检查“require”变量
对于(int i=0;i

有人能帮我吗

我自己问题的解决方案。请参见imagelist+构造函数

public class RSSReader {
    //Lists to store headlines, descriptions & images
    String url = "http://www.nu.nl/rss/Algemeen";
    List<String> titleList;
    List<String> descriptionList;
    List<String> imageList;
    public RSSReader() throws IOException{
        titleList = readRSS(url, "<title>", "</title>");
        descriptionList= listFilter(readRSS(url, "<description>", "</description>"), "&amp;nbsp;", "");
        imageList = readRSS(url, "<enclosure url \"", "\" length=\"0\" type=\"image/jpeg\"</enclosure>");
    }
    public List<String> readRSS(String feedUrl, String openTag, String closeTag) throws IOException, MalformedURLException {
        URL url = new URL(feedUrl);
        BufferedReader reader= new BufferedReader(new InputStreamReader(url.openStream()));

        String currentLine;
        List<String> tempList = new ArrayList<String>();
        while((currentLine = reader.readLine()) != null){
            Integer tagEndIndex = 0;
            Integer tagStartIndex = 0;
            while (tagStartIndex >= 0){
                tagStartIndex = currentLine.indexOf(openTag, tagEndIndex);
                if(tagStartIndex >= 0){
                    tagEndIndex = currentLine.indexOf(closeTag, tagStartIndex);
                    tempList.add(currentLine.substring(tagStartIndex + openTag.length(), tagEndIndex) + "\n");
                }
            }
        }
        tempList.remove(0);
        return tempList;
    }

    public List<String> getDesciptionList(){
        return descriptionList;
    }

    public List<String> getTitleList(){
        return titleList;
    }
    public List<String> getImageList(){
        return imageList;
    }

    public List<String> listFilter(List<String> tempList, String require, String replace){
        //Creates new List
        List<String> newList = new ArrayList<>();
        //Loops through old list and checks for the 'require' variable
        for(int i = 0; i < tempList.size(); i++){
            if(tempList.get(i).contains(require)){
                newList.add(tempList.get(i).replace(require, replace));
            }
            else{
                newList.add(tempList.get(i));
            }
        }
        return newList;
    }


}
公共类RSSReader{
//用于存储标题、说明和图像的列表
字符串url=”http://www.nu.nl/rss/Algemeen";
列表标题列表;
列表描述列表;
列表图像列表;
public RSSReader()引发IOException{
titleList=readRSS(url,“,”);
descriptionList=listFilter(readRSS(url,“,”),“&;nbsp;”,”);
imageList=readRSS(url,“