0

我正在使用这样的 XML:

<ListOfLore>
      <q1:Lore xmlns:q1="http://www.rold.com/Data.xsd">                
        <q1:LoreNumber>15642</q1:LoreNumber>        
      </q1:Lore>
      <q1:Lore xmlns:q1="http://www.rold.com/Data.xsd">
        <q1:LoreNumber>15644</q1:LoreNumber>        
      </q1:Lore>
</ListOfLore>

我正在这样做,但我什么也没得到

var lores = (from ListOfLore in pjs.Descendants("ListOfLore")
                              from Lore in ListOfLore.Descendants()
                              where Lore.Name.LocalName == ("Lore") 
                              select Lore);

我想LoreListOfLore

4

1 回答 1

4
XNamespace ns = "http://www.rold.com/Data.xsd";
var lores = (from lore in pjs.Descendants(ns + "Lore")
             select lore);

正如 Jon 所说,您不需要查询语法。以下内容更简短、更清晰:

XNamespace ns = "http://www.rold.com/Data.xsd";
var lores = pjs.Descendants(ns + "Lore");
于 2012-11-07T13:15:57.740 回答