How to cast XPathEvalute when it can be XElement or XAttribute?

Aoltrfsenos

New Member
So I have this code:\[code\]List<PriceDetail> prices = (from item in xmlDoc.Descendants(shop.DescendantXName) select new PriceDetail { Price = GetPrice(item.Element(shop.PriceXPath).Value), GameVersion = GetGameVersion(((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value, item.Element(shop.PlatformXPath).Value), Shop = shop, Link = item.Element(shop.LinkXPath).Value, InStock = InStock(item.Element(shop.InStockXPath).Value) }).ToList<PriceDetail>();\[/code\]The problem I have is this code:\[code\]((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value\[/code\]Sometimes the item could be XElement and then the casting doesn't work. So what I need is a Cast that works with both XAttribute and XElement.Any suggestion?
 
Back
Top