【问题标题】:Fill List<> from XML respond从 XML 响应中填充 List<>
【发布时间】:2012-04-10 13:38:48
【问题描述】:

我的问题是如何到达

<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

提前致谢

【问题讨论】:

  • 只需在 locationid 上调用 .element 即可下一级。

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


【解决方案1】:
item.Element("locationid").Element("city").Value

【讨论】:

  • 哇,我现在觉得自己很愚蠢,因为我没有尝试过。但是非常感谢:D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-20
  • 1970-01-01
相关资源
最近更新 更多