windows phone xml filter

本文关键字:filter xml phone windows | 更新日期: 2023-09-27 18:31:25

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

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

我想按类别过滤这些内容,但想在一个页面上过滤类别 3、5、6,在其他页面上过滤类别 25、99 等。我用过这个:

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

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();
        }
    }
}

windows phone xml filter

        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);
        }