首页 > 编程语言 >c# XElement linq filter

c# XElement linq filter

时间:2022-08-30 17:35:06浏览次数:55  
标签:return string c# xEl filter XElement static

using System.Xml;

using System.Xml.Linq;

 

       // 调用

static private void InitIncrementalSanctionsReferencesList(this XmlReader reader, PFA pfa)

        {

            XElement xEl = XElement.ReadFrom(reader) as XElement;

           if (xEl != null)

            {

               var sanctionsReferencesElements = from el in xEl.Elements().Where(q => ListTypeFilter(q.GetAttributeValue("name"), this.ListType) == true) select el;

           }

        }

 

       // 定义

       static bool ListTypeFilter(string hand, List<string> filters) => filters.Any(filter => hand.Contains(filter));

 

       static private string GetAttributeValue(this XElement ele, string xname)

        {

           var attr = ele.Attribute(xname);

           if (attr != null)

                return attr.Value.Trim();

           return string.Empty;

        }

 

static public List<string> ListType { get { return new List<string> { "EC ", "EU ", "UN ", "UK " }; } }

 

标签:return,string,c#,xEl,filter,XElement,static
From: https://www.cnblogs.com/hofmann/p/16640171.html

相关文章