嗨,我有如下 xml
<BrowserMix>
<BrowserProfile Percentage="10">
<Browser Name="Internet Explorer 10.0" MaxConnections="6">
<Headers>
<Header Name="User-Agent" Value="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)" />
<Header Name="Accept" Value="*/*" />
<Header Name="Accept-Language" Value="{{$IEAcceptLanguage}}" />
<Header Name="Accept-Encoding" Value="GZIP" />
</Headers>
</Browser>
</BrowserProfile>
<BrowserProfile Percentage="85">
<Browser Name="Internet Explorer 9.0" MaxConnections="6">
<Headers>
<Header Name="User-Agent" Value="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" />
<Header Name="Accept" Value="*/*" />
<Header Name="Accept-Language" Value="{{$IEAcceptLanguage}}" />
<Header Name="Accept-Encoding" Value="GZIP" />
</Headers>
</Browser>
</BrowserProfile>
<BrowserProfile Percentage="5">
<Browser Name="WinPhone8" MaxConnections="6">
<Headers>
<Header Name="User-Agent" Value="Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)" />
<Header Name="Accept" Value="*/*" />
<Header Name="Accept-Language" Value="{{$IEAcceptLanguage}}" />
<Header Name="Accept-Encoding" Value="GZIP" />
</Headers>
</Browser>
</BrowserProfile>
</BrowserMix>
我想使用 linq 查询获取“百分比”和浏览器名称的值属性?提前致谢?
而Linq查询是
var browserQuery = (from dt in xdoc.Descendants("Root").AsEnumerable()
select new
{
BrowserMix = dt.Attribute("Percentage").Value.ToString(),
Name = dt.Attribute("Name").Value.ToString()
});
我总是没有得到枚举产量结果..