public static IEnumerable <XElement> ElementsBy(this XContainer container, AttributeName attributeName) { Contract.Requires(container.IsNotNull()); Contract.Requires(attributeName.IsNotNull()); var elements = container.Descendants().Where(item => item.Attributes().Any(a => a.Name.LocalName.Equals(attributeName.Value))); return(elements); }
public static XElement ElementBy(this XContainer container, AttributeName attributeName) { Contract.Requires(container.IsNotNull()); Contract.Requires(attributeName.IsNotNull()); var element = container.ElementsBy(attributeName).FirstOrDefault(); return(element); }