複数の属性を解析しようとしていますが、成功しません。
私がよく解析しているこれらの属性:
<id>..</id>
<published>..</published>
<content>..</content>
<title>..</title>
解析した xml の画像と必要なデータ:
しかし、タグ付きの属性を取得する必要があります:
<media:thumbnail url='http://ww.../> </media:thumbnail>
<media:content url='http://ww.../> </<media:content>
私はどこかで、sax parse がこれをサポートしていないことを読みました。
私はコードを使用して解析を実行しています:
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(
解決策はありますか??
ありがとう!