我从XML加载关于感兴趣的城市的点,我的XML结构的一些信息是这样的:的LINQ to XML查询
<InterestPoint>
<id>2</id>
<name>Residencia PAC</name>
<images>
<image>C:\Pictures\Alien Places in The World\20090625-alien11.jpg</image>
<image>C:\Alien Places in The World\20090625-alien13.jpg</image>
</images>
<desc>blah blah blah blah</desc>
<Latitude>40.286458</Latitude>
<Longitude>-7.511921</Longitude>
</InterestPoint>
遇到麻烦来检索图像的信息,我m只能得到一个图像,但在这个例子中有两个。我使用LINQ查询是:
CityPins = (from c in PointofInterest.Descendants("InterestPoint")
select new InterestPoint
{
// = c.Attribute("Latitude").Value,
//longitude = c.Attribute("Longitude").Value,
Name = c.Element("nome").Value,
LatLong = new VELatLong(double.Parse(c.Element("Latitude").Value), double.Parse(c.Element("Longitude").Value)),
Desc = c.Element("descricao").Value,
Images = (from img in c.Descendants("imagens")
select new POIimage
{
image = new Uri(img.Element("imagem").Value),
}).ToList<POIimage>(),
}).ToList<InterestPoint>();
图片是List<POIimages>
其中POIimage是一个开放的领域类。
有人可以帮我解决这个问题吗?
可以有多个''元素? –
SLaks
2010-06-07 16:47:35