Windows Phone XML解析

时间:2013-11-25 12:35:49

标签: xml windows-phone

我正在阿尔巴尼亚创建一个电视应用程序。我用xml解析文档,一切都很好但有时xml在页面上有一些错误,当它试图解析它时,我给了我错误。这里是代码

public Lajme1()
    {
        InitializeComponent();
        WebClient downloader = new WebClient();
        Uri uri = new Uri("http://top-channel.tv/rss/newsfeed5.xml", UriKind.Absolute);
        downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(EmployeesDownloaded);
        downloader.DownloadStringAsync(uri);

}

void EmployeesDownloaded(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Result == null || e.Error != null)
        {
            MessageBox.Show("There is a error");
            return;
        }
        else
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Employees));
            XDocument document = XDocument.Parse(e.Result);
            Employees employees = (Employees)serializer.Deserialize(document.CreateReader());
            lajme_1.ItemsSource = employees.Collection;

        }

    }

错误发生在XDocument document = XDocument.Parse(e.Result);

0 个答案:

没有答案