我想解析多个属性,但没有成功。如何使用SAX解析rss-feed,解析其他方法?
这些属性我很解析得好:
<id>..</id>
<published>..</published>
<content>..</content>
<title>..</title>
我在解析XML和数据,我需要的图像: 但我需要与标签的属性:
<media:thumbnail url='http://ww.../> </media:thumbnail>
<media:content url='http://ww.../> </<media:content>
我在某处读到萨克斯解析不支持这样做,我不明白这是真的。
我使用的代码进行解析:
public class YoutubePARSER {
private static final String LOGTAG = "LogsAndroid";
private ArrayList<YoutubeVO> videos = new ArrayList<YoutubeVO>();
private YoutubeVO video;
private URL rssUrl;
final String myString = "http://www.w3.org/2005/Atom";
SAXParserFactory parser = SAXParserFactory.newInstance();
public YoutubePARSER(String url)
{
try
{
this.rssUrl = new URL(url);
}
catch (MalformedURLException e)
{
throw new RuntimeException(e);
}
}
public ArrayList<YoutubeVO> parse()
{
RootElement root = new RootElement(myString, "feed");
Element itemPlace = root.getChild(myString, "entry");
itemPlace.setStartElementListener(new StartElementListener(){
public void start(Attributes attrs){
video = new YoutubeVO();
}
});
itemPlace.setEndElementListener(new EndElementListener(){
public void end() {
videos.add(video);
}
});
itemPlace.getChild(myString, "id").setEndTextElementListener(
new EndTextElementListener(){
public void end(String body) {
video.setId(body);
}
});
itemPlace.getChild(myString, "published").setEndTextElementListener(
new EndTextElementListener(){
public void end(String body) {
video.setPublished(body);
}
});
我试图解析下列方式领域,没有成功:
itemPlace.getChild(myString, "media:thumbnail").setEndTextElementListener(
itemPlace.getChild(myString, "media").setEndTextElementListener(
itemPlace.getChild(myString, "thumbnail").setEndTextElementListener(
itemPlace.getChild(myString, "media:thumbnail url").setEndTextElementListener(
任何解决方案?
谢谢!