【问题标题】:Problem with LINQ to XMLLINQ to XML 的问题
【发布时间】:2011-09-07 14:30:46
【问题描述】:

我有一个 xml

<MyRoot>
  <ITEM>
    <Created>Customer created Aug 22 2011  9:28AM
Contact Details Last Updated Aug 22 2011  9:39AM</Created>
    <Name>SomeName</Name>
    <Address>High way to hell</Address>
    <Phone1>123456</Phone1>
    <Phone2></Phone2>
    <Mobile>654321</Mobile>
    <Email>myemail@gmail.com</Email>
  </ITEM>
</MyRoot>

它的值是 xdoc ([System.RuntimeType] {System.Xml.Linq.XDocument} System.RuntimeType)

当我执行这个时:

var items= xdoc.Root.Elements("Item");

我得到类型的元素

{System.Xml.Linq.XContainer+<GetElements>d__11} System.Type {System.RuntimeType}

元素个数为 0。

我怎样才能得到物品的集合?

【问题讨论】:

    标签: c# .net xml linq-to-xml


    【解决方案1】:

    XML 区分大小写。

    var items= xdoc.Root.Elements("ITEM");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多