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");
}
}
}
if (tempList.size() > 0) {
if(openTag.contains("title")){
tempList.remove(0);
tempList.remove(0);
}
else if(openTag.contains("desc")){
tempList.remove(0);
}
}
return tempList;
}
我写了一段代码来读取RSS源。一切都运行良好,但当解析器找到像这样的字符

时,它就会中断。这是因为它无法找到结束标记,因为XML已经被转义了。我不知道如何在我的代码中修复它。有谁能帮我解决这个问题吗?