LINQ to XML 的问题

发布于 2024-12-03 18:55:39 字数 938 浏览 0 评论 0原文

我有一个 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>[email protected]</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。

我怎样才能获得物品收藏?

I have a 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>[email protected]</Email>
  </ITEM>
</MyRoot>

and it's a value of xdoc ([System.RuntimeType] {System.Xml.Linq.XDocument} System.RuntimeType)

When I execute this:

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

i get element of type

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

and with 0 as number of elements.

How can I get collection of items ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏天碎花小短裙 2024-12-10 18:55:39

XML 区分大小写。

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

XML is case-sensitive.

var items= xdoc.Root.Elements("ITEM");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文