我已经创建了自己的DefaultHandler来解析rss提要,并且对于大多数提要它工作正常,但是,对于ESPN,由于ESPN格式化网址的方式,它正在切断部分文章网址.来自ESPN的完整文章网址的一个例子..
http://sports.espn.go.com/nba/news/story?id=5189101&campaign=rss&source=ESPNHeadlines
Run Code Online (Sandbox Code Playgroud)
问题是由于某种原因,DefaultHandler字符方法只从包含上述url的标记中获取.
http://sports.espn.go.com/nba/news/story?id=5189101
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,它正在从&符号转义码和之后的网址中删除所有内容.如何让SAX解析器不在此转义码中删除我的字符串?对于参考 这是我的角色方法..
public void characters(char ch[], int start, int length) {
String chars = (new String(ch).substring(start, start + length));
try {
// If not in item, then title/link refers to feed
if (!inItem) {
if (inTitle)
currentFeed.title = chars;
} else {
if (inLink)
currentArticle.url = new URL(chars);
if (inTitle)
currentArticle.title = chars;
if (inDescription)
currentArticle.description = chars;
if (inPubDate)
currentArticle.pubDate = chars;
if (inEnclosure) {
}
}
} catch (MalformedURLException e) {
Log.e("RSSReader", e.toString());
} …Run Code Online (Sandbox Code Playgroud)