1

我正在尝试为电视频道开发应用程序。我有一个 XML 文件并已对其进行了解析。现在的问题是我想过滤它。这是 XML 文件:

http://top-channel.tv/rss/videofeed.xml

我想按类别过滤,但想在一页中过滤类别 3、5、6,在另一页上过滤类别 25、99 等。我用过这个:

当我单击按钮打开带有http://youtube.com/whatch?v= + 图标的网页时,LajmeVideo.icon 上的图标。这是我所有的源代码

namespace Top_Channel
{
    public partial class Video : PhoneApplicationPage
    {
        public Video()
        {
            InitializeComponent();

            grdLoading.Visibility = Visibility.Visible;
            progressBar.IsIndeterminate = true;

            WebClient webclient = new WebClient();
            webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);
            webclient.DownloadStringAsync(new Uri("http://top-channel.tv/rss/videofeed.xml"));
        }

        void webclient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {

            if (e.Error != null)
            {
                MessageBoxResult m = MessageBox.Show("Ju lutem verifikoni qe te keni internet ne telefonin tuaj", "Ska Internet", MessageBoxButton.OK);

            }

            XDocument doc = XDocument.Parse(e.Result);
            var videos = doc.Descendants().Where(x => x.Name == "video");
            List<LajmeVideo> lajmes = new List<LajmeVideo>();
            foreach (var item in videos)
            {
                var category = item.Descendants().Where(x => x.Name == "category").FirstOrDefault();
                var title = item.Descendants().Where(x => x.Name == "title").FirstOrDefault();
                var icon = item.Descendants().Where(x => x.Name == "youtubeid").FirstOrDefault();
                if (category.Value == "25" || category.Value == "99")
                {
                    lajmes.Add(new LajmeVideo()
                    {
                        kategoria = category.Value,
                        title = title.Value,
                        icon = icon.Value,
                    });
                }
                lajme_video.ItemsSource = lajmes;
                var uri = new Uri("http://www.youtube.com/watch?v=" + item.Descendants().Where(x => x.Name == "youtubeid").FirstOrDefault().Value);
            }

            progressBar.IsIndeterminate = false;
            grdLoading.Visibility = Visibility.Collapsed;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask webBrowserTask = new WebBrowserTask();
            webBrowserTask.Uri = new Uri("http://www.youtube.com/watch?v=My2FRPA3Gf8", UriKind.Absolute);
            webBrowserTask.Show();
        }
    }
}
4

1 回答 1

0
        XDocument doc = XDocument.Parse(Properties.Resources.videofeed);
        var videos = doc.Descendants().Where(x => x.Name == "video");
        List<LajmeVideo> lajmes = new List<LajmeVideo>();
        foreach (var item in videos)
        {
            var cat = item.Descendants().Where(x => x.Name == "category").FirstOrDefault();
            if (cat.Value == "25" || cat.Value == "99")
            {
                //addtolist;
            }
            var uri = new Uri("http://www.youtube.com/watch?v=" + item.Descendants().Where(x => x.Name == "youtubeid").FirstOrDefault().Value);
        }
于 2013-09-13T23:28:02.700 回答