private static XAttribute GetAttribute(XElement element, string attributeName) { var x = element.Attribute(attributeName); if (x == null) { throw new InvalidOperationException(string.Format("Attribute {0} not found.", attributeName)); } return x; } }