开发者

Searching in xml with linq

开发者 https://www.devze.com 2022-12-09 04:17 出处:网络
I want to searching in a xml file. this is my linq sentece. string _sSemptom= \"try\"; XElement xe =from c in xdSemptom.Elements().Elements().Elements()

I want to searching in a xml file. this is my linq sentece.

string _sSemptom  = "try";
XElement xe =  from c in xdSemptom.Elements().Elements().Elements()
                         .Elements().Attributes("Isim")
               where c.Value.Le开发者_Python百科ngth >= _sSemptom.Length &&
                     c.Value.Contains(_sSemptom)
               select c.Parent

I can find the XElement that way, but if _sSemptom is "Try" I can't find it. How can I search using upper and lower case variations?

Thanks for your helps.


Edit: Actually, it turns out there isn't a StringComparison overload for Contains(). You can use IndexOf() instead:

c.Value.IndexOf(_sSemptom, StringComparison.OrdinalIgnoreCase) > -1
0

精彩评论

暂无评论...
验证码 换一张
取 消