Geeks With Blogs
Sharvan Dhaka blog

The following code shows to how to perform a case-sensitive search in .NET using XPath.

and contains is used as like operator in xpath.

XML File:
<?xml version="1.0" encoding="utf-8"?>

Code File:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Page Language="C#" Debug="true" %>

<SCRIPT runat="server">
void Page_Load(object sender, System.EventArgs e)
        XmlDocument xmlDoc = new XmlDocument();
 XmlNodeList nodeList = xmlDoc.SelectNodes("Users/User[contains(translate(Name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate('Sharvan', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]");

1. Case of matching the beginning of some text.
miCommunities% LIKE where wildcard is at end

 Corresponding XPath expression predicate,
[ starts-with( Name , 'miCommunities')]

2. Case of matching within some text.
%miCommunities% LIKE where there is a wildcard at both ends

 Corresponding XPath expression predicate,
[ contains( Name , 'miCommunities')]
Posted on Sunday, October 15, 2006 6:37 PM Xml & Xpath , c# | Back to top

Comments on this post: Perform a Case-IN sensitive Search in .NET Using XPath

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Sharvan Dhaka | Powered by: