0
私は問題を持っている...私はこの方法でXMLを解析しています:のWindows Phone(のような<media:group>)
public MainPage(){
InitializeComponent();
WebClient client = new WebClient();
client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
Uri url = new Uri("http://gdata.youtube.com/feeds/api/users/my_channel/uploads/?alt=rss&prettyprint=true", UriKind.Absolute);
client.OpenReadAsync(url);
}
public void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e){
try{
var xml=XDocument.Load(e.Result);
var results=from row in xml.Element("rss").Element("channel").Elements().Where(element=>{
return(element.Name.LocalName == "item");
})select row;
List<MioVideo> videoList = new List<MioVideo>();
int totalevideo = 0;
foreach (var result in results){
XElement title=result.Elements().Where(element => {
return element.Name.LocalName == "title";
}).FirstOrDefault();
XElement description = result.Elements().Where(element =>
{
return element.Name.LocalName == "description";
}).FirstOrDefault();
XElement mylink = result.Elements().Where(element =>
{
return element.Name.LocalName == "link";
}).FirstOrDefault();
String id_video = mylink.Value;
id_video = id_video.Substring(31,11);
videoList.Add(new MioVideo(title.Value, description.Value, mylink.Value,"http://img.youtube.com/vi/"+id_video+"/hqdefault.jpg"));
totalevideo++;
}
listavideo.ItemsSource = videoList;
}
catch (Exception c){
MessageBox.Show(c.Message);
}
}
私は別のノードを解析したいのですが、それは、Aがあります名前のように、私はそれを解析し、yt:duration内の値を取得する方法を知らない。
誰かがheml me ???他の言葉で
、私のXMLは次のとおりです。
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:app='http://purl.org/atom/app#' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' version='2.0'>
<channel>
<description></description>
<atom:id>http://gdata.youtube.com/feeds/api/users/mychannel/uploads</atom:id>
<lastBuildDate>Tue, 03 Jan 2012 12:24:02 +0000</lastBuildDate>
<category domain='http://schemas.google.com/g/2005#kind'>http://gdata.youtube.com/schemas/2007#video</category>
<title>Uploads by MyChannel</title>
<image>
<url>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</url>
<title>Uploads by MyChannel</title>
<link>http://www.youtube.com/profile?user=MyChannel#p/u</link>
</image>
<link>http://www.youtube.com/profile?user=MyChannel#p/u</link>
<atom:link rel='self' href='http://gdata.youtube.com/feeds/api/users/MyChannel/uploads?alt=rss&start-index=1&max-results=25'/>
<managingEditor>MyChannel</managingEditor>
<generator>YouTube data API</generator>
<openSearch:totalResults>75</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
<item>
<guid isPermaLink='false'>http://gdata.youtube.com/feeds/api/videos/Qt6wF29Ytzo</guid>
<pubDate>Fri, 23 Dec 2011 12:10:17 +0000</pubDate>
<atom:updated>2011-12-23T13:22:34.000Z</atom:updated>
<category domain='http://schemas.google.com/g/2005#kind'>http://gdata.youtube.com/schemas/2007#video</category>
<category domain='http://gdata.youtube.com/schemas/2007/categories.cat'>Comedy</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>Natale</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>paolo</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>labati</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>auguri</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>comicità</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>italiana</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>mychannel</category>
<category domain='http://gdata.youtube.com/schemas/2007/keywords.cat'>MyChannel</category>
<title>mio video</title>
<description>Tanti auguri di Buon Natale!!!</description>
<link>http://www.youtube.com/watch?v=Qt6wF29Ytzo&feature=youtube_gdata</link>
<author>MyChannel</author>
<gd:comments>
<gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/Qt6wF29Ytzo/comments' countHint='0'/>
</gd:comments>
<media:group>
<media:category label='Commedie' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Comedy</media:category>
<media:content url='http://www.youtube.com/v/Qt6wF29Ytzo?version=3&f=user_uploads&app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='17' yt:format='5'/>
<media:content url='rtsp://v4.cache4.c.youtube.com/CigLENy73wIaHwk6t1hvF7DeQhMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='17' yt:format='1'/>
<media:content url='rtsp://v3.cache5.c.youtube.com/CigLENy73wIaHwk6t1hvF7DeQhMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='17' yt:format='6'/>
<media:description type='plain'>Tanti auguri di Buon Natale!!!</media:description>
<media:keywords>Natale, paolo, labati, auguri, comicità, italiana, mychannel, MyChannel</media:keywords>
<media:player url='http://www.youtube.com/watch?v=Qt6wF29Ytzo&feature=youtube_gdata_player'/>
<media:thumbnail url='http://i.ytimg.com/vi/Qt6wF29Ytzo/0.jpg' height='360' width='480' time='00:00:08.500'/>
<media:thumbnail url='http://i.ytimg.com/vi/Qt6wF29Ytzo/1.jpg' height='90' width='120' time='00:00:04.250'/>
<media:thumbnail url='http://i.ytimg.com/vi/Qt6wF29Ytzo/2.jpg' height='90' width='120' time='00:00:08.500'/>
<media:thumbnail url='http://i.ytimg.com/vi/Qt6wF29Ytzo/3.jpg' height='90' width='120' time='00:00:12.750'/>
<media:title type='plain'>Paolo Labati - Buon Natale</media:title>
<yt:duration seconds='17'/>
</media:group>
<yt:statistics favoriteCount='1' viewCount='432'/>
</item>
</channel>
</rss>
と私はYTから値を取得する必要があります。所要時間とメディア:サムネイル
申し訳ありませんが、私のコードで例を挙げることはできますか? 私は理解していない、私はwp7で新しいです – Zak
@Zakが更新されました。上に戻る –
エラーを取得する:responseElement、現在のコンテキストに存在しません – Zak