1

无论如何要阅读此xml中的特定行吗?

http://i.stack.imgur.com/hDPIg.jpg

                var guide = from query in dataFeed.Descendants("MaxPayne3")
                                                 select new NewGamesClass
                                                 {
                                                     GameTitle = (string)query.Element("Title"),
                                                     Gamedescription = (string)query.Element("Description"),
                                                     GameGuide = (string)query.Element("Guide")
                                                 };
                GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameGuide.StartsWith("See 'Payne In The Ass'")).Take(1);

这将显示 xml 中的所有指南。

这项工作:

                var guide = from query in dataFeed.Descendants("MaxPayne3")
                                                 select new NewGamesClass
                                                 {
                                                     GameTitle = (string)query.Element("Title"),
                                                     Gamedescription = (string)query.Element("Description"),
                                                     GameGuide = (string)query.Element("Guide")
                                                 };
                //GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameGuide.StartsWith("See 'Payne In The Ass'")).Take(1);
                GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameTitle.StartsWith("Serious"));

所以从 XML 中的第一个子元素开始。

4

1 回答 1

0

只需使用 where 子句继续您的语句:(根据您的需要更改条件)

 var guides = from query in dataFeed.Descendants("MaxPayne3")
                                             select new NewGamesClass
                                             {
                                                 GameGuide = (string)query.Element("Guide")

                                             };

AchivementsListBox.ItemsSource = guides.Where( ngc => ngc.GameGuide.StartsWith("Chapter 4:"));
于 2012-07-17T11:30:49.163 回答