问题
XElement.Descendants () method accepts name of element to be find.
But it is case-sensitive is there any way to make it case-insensitive
回答1:
You can use this:
element.Descendants()
.Where(x => string.Compare(x.Name, filter,
StringComparison.OrdinalIgnoreCase) == 0);
回答2:
This way worked for me..
XElement selectedElement = doc.Descendants().Where(x =>
String.Equals((string)x.Attribute("name"), filtertext,
StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
来源:https://stackoverflow.com/questions/14977166/xelement-descendants-make-it-case-insensitive