2012-07-17 57 views
1

無論如何閱讀這個XML中的特定行嗎?閱讀具體這行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中的第一個孩子開始。

回答

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:")); 
+0

如果我這樣做,有是說,它會顯示所有的人都一樣的另一個導向。例如:如果指南3 =故事相關,指南39 =故事相關,則會顯示兩個指南。 – iamrelos 2012-07-17 11:53:35

+0

如果您只需要一個,請繼續使用.Take(1)語句。 – 2012-07-17 12:28:34

+0

對不起,我也想這個標題,描述和圖像。 – iamrelos 2012-07-17 13:25:20