Example #1
0
        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);
        }
Example #2
0
        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);
        }