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 " }; } }
c# XElement linq filter
最新推荐文章于 2023-11-04 21:45:40 发布