First XML Element from Any Namespace - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

First XML Element from Any Namespace

Demo Code


using System.Xml.Linq;
using System.Linq;
using System.Collections.Generic;

public class Main{
        public static XElement FirstAnyNS<T>(this IEnumerable<T> source, string localName) where T : XContainer
        {/*from w ww.  ja  va2  s.co  m*/
            return source.Elements().Where(e => e.Name.LocalName == localName).FirstOrDefault();
        }
}

Related Tutorials