I've tried this to search for the word 'apple' within 'DESCRIPTION' of all 'PRODUCT' elements in an xml document:
Dim fruit As XmlNodeList = doc.SelectNodes("//PRODUCT[translate(., 'ABCDEFGHJIKLMNOPQRSTUVWXYZ', 'abcdefghjiklmnopqrstuvwxyz') = contains(DESCRIPTION,'apple')]")
This works however if I change it to for example 'applE' it doesn't.
There are loads of variations on the syntax I've found on Google but it's all a bit confusing.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Thanks but I already found some of those links to get to my solution posted above, particularly the last link which is the same as what I have except I am using "contains". Trouble is it's not working and I could use some help!
Member
4 Points
19 Posts
XmlPath case insensitive search
Nov 26, 2014 06:48 PM|ma701ss|LINK
Hi,
I've tried this to search for the word 'apple' within 'DESCRIPTION' of all 'PRODUCT' elements in an xml document:
This works however if I change it to for example 'applE' it doesn't.
There are loads of variations on the syntax I've found on Google but it's all a bit confusing.
Any help appreciated.
Thanks
All-Star
45489 Points
7008 Posts
Microsoft
Re: XmlPath case insensitive search
Nov 28, 2014 03:33 AM|Zhi Lv - MSFT|LINK
Hi ma701ss,
As for this issue, here are some similar threads and useful articles. Please refer to them.
XMLDocument SelectNodes: http://forums.asp.net/t/1498407.aspx?XMLDocument+SelectNodes
Using XPath translate() to ignore case in xPath query: http://forums.asp.net/t/1214767.aspx?Using+XPath+translate+to+ignore+case+in+xPath+query
Case-insensitive XPath in .NET: http://blogs.msdn.com/shjin/archive/2005/07/22/442025.aspx
Use XPath to Perform a Case-Insensitive Search with MSXML: http://support.microsoft.com/kb/315719
Best Regards,
Dillion
Member
4 Points
19 Posts
Re: XmlPath case insensitive search
Dec 03, 2014 04:34 PM|ma701ss|LINK
Thanks but I already found some of those links to get to my solution posted above, particularly the last link which is the same as what I have except I am using "contains". Trouble is it's not working and I could use some help!
All-Star
35149 Points
9075 Posts
Re: XmlPath case insensitive search
Jan 21, 2015 09:50 AM|smirnov|LINK
The right syntax is
because contains() is used like
and changing to lower case is
Complete demo: https://dotnetfiddle.net/kUDTUr