在VB.NET中查询LINQ到XML提要

在VB.NET中查询LINQ到XML提要,vb.net,linq,linq-to-xml,Vb.net,Linq,Linq To Xml,我通过XDocument.load(uri)或XElement.load(uri)加载以下XML。我无法通过LINQ获取元素集合 下面是我试图查询的XML片段: <assetCollection xmlns="tag:aisle7.net,2009:/api/1.0"> <title>All Assets</title> <description>Collection containing all assets in the

我通过
XDocument.load(uri)
XElement.load(uri)
加载以下XML。我无法通过LINQ获取
元素集合

下面是我试图查询的XML片段:

<assetCollection xmlns="tag:aisle7.net,2009:/api/1.0">
      <title>All Assets</title>
      <description>Collection containing all assets in the system</description>
      <resourcePath>/us/assets/~all</resourcePath>
      <link rel="self" href="http://web.aisle7.net/api/1.0/us/assets/~all?apikey=1234567890&amp;Format=XML" />
      <link rel="first" href="http://web.aisle7.net/api/1.0/us/assets/~all?apikey=1234567890&amp;Format=XML" />
      <link rel="next" href="http://web.aisle7.net/api/1.0/us/assets/~all?apikey=1234567890&amp;Format=XML&amp;page=2" />
      <link rel="last" href="http://web.aisle7.net/api/1.0/us/assets/~all?apikey=1234567890&amp;Format=XML&amp;page=66" />
      <updated>2011-03-01T19:01:49.667Z</updated>
      <assets>
        <asset>
          <title>Homeopathy</title>
          <resourcePath>/us/assets/toc/homeopathy</resourcePath>
          <link rel="alternate" href="http://web.aisle7.net/api/1.0/us/assets/toc/homeopathy?apikey=1234567890&amp;Format=XML" />
          <updated>2011-03-01T19:01:49.667Z</updated>
        </asset>
        <asset>
          <title>What Is Homeopathy?</title>
          <resourcePath>/us/assets/generic/what-is-homeopathy_13615_1</resourcePath>
          <link rel="alternate" href="http://web.aisle7.net/api/1.0/us/assets/generic/what-is-homeopathy_13615_1?apikey=1234567890&amp;Format=XML" />
          <updated>2011-03-01T19:00:17.680Z</updated>
        </asset>
    ...
试一试


以下是使用xml文本语法的版本:

Dim xml = XElement.Load(uri)
Dim q = From a In xml.<assets>...<asset> 
        Select a
Dim xml=XElement.Load(uri)
Dim q=来自xml中的。。。。
选择一个

没有骰子。调试“资产”会在检查器中显示消息“抛出了类型为“System.Linq.SystemCore_EnumerableDebugViewEmptyException”的异常。”。有什么想法吗?你刚刚发布的第二个代码段抛出了一个NullReferenceException:(@Mark显然它不喜欢你的`xmlns=“tag:aisle7.net,2009:/api/1.0”“。如果我删除了它,两个代码段都可以正常工作。我刚刚发现自己……有没有办法让LINQ忽略名称空间?@Mark cool。也可以查看这篇文章
Dim assets = From a In XElement.Load(uri).Descendants("asset") Select a
Dim assets = From a In XDocument.Load(uri).Root.Element("assets").Elements("asset") Select a
Dim xml = XElement.Load(uri)
Dim q = From a In xml.<assets>...<asset> 
        Select a