C# XDocument Attribute Performance Concerns
- by Dested
I have a loaded XDocument that I need to grab all the attributes that equal a certain value and is of a certain element efficiently. My current
IEnumerable<XElement> vm;
if (!cacher2.TryGetValue(name,out vm)) {
vm = project.Descendants(XName.Get(name));
cacher2.Add(name, vm);
}
XElement[] abdl = (vm.Where(a => a.Attribute(attribute).Value == ab)).ToArray();
cacher2 is a Dictionary<string,IEnumerable<XElement>> The ToArray is so I can evaluate the expression now. I dont think this causes any real speed concerns. The problem is the Where itself. I am searching through anywhere from 1 to 10k items.
Any help?