填写清单<>来自XML回应

时间:2012-04-10 13:38:49

标签: c# xml linq windows-phone-7

我的问题是如何才能达到

<xml>
 <item>
  <eventid>1</eventid>
  <eventname>Test</eventname>
  <startdate>2012-04-30 12:00:00</startdate>
  <locationid>
    <locationid>1</locationid>
    <city>Amsterdam</city>    <-----------This field
    <venuename>Java-eiland</venuename>
  </locationid>
 </item>
</xml>

填写清单时

eventInfo = (from item in events.Descendants("item")
                         select new Event
                         {
                             EventId = Convert.ToInt16(item.Element("eventid").Value),
                             EventName = item.Element("eventname").Value,
                             EventCity = ??????????
                         }).ToList();

我找到了Using LINQ to fill a List<object> from xml 但他们并没有像我想要的那样深入挖掘XML

提前致谢

1 个答案:

答案 0 :(得分:3)

item.Element("locationid").Element("city").Value