我正在尝试使用 xdoc 和 LINQ 在以下 xml 文件中获取样式列表。
<?xml version="1.0" encoding="UTF-8"?>
<kml>
<Document>
<Style id="style62">
<IconStyle>
<Icon>
<href>http://maps.gstatic.com/mapfiles/ms2/micons/yellow-dot.png</href>
</Icon>
</IconStyle>
</Style>
</Document>
</kml>
为了在同一个 LINQ 选择中获取 ID="style62" 以及 href 中的值,我无法正确使用语法,有人可以帮忙吗?
var styles = xdoc.Descendants(ns + "Style")
.Select(s => new
{
//HELP!?!
//E.G
//
//id = s.something (style62)
//href = s.something (url)
}).ToList();