public static int GetRanking(this XElement rankingElement)
{
var val = (rankingElement.Elements("rank")
.Where(p => p.Attribute("id").Value == "1")
.Select(p => p.Attribute("value").Value)).SingleOrDefault();
int rank;
if (val == null)
rank = -1;
else if (val.ToLower().Trim() == "not ranked")
rank = -1;
else if (!int.TryParse(val, out rank))
rank = -1;
return rank;
}
}