|
Average Rating: 2.3/5 | Rate this item | 3 users have rated this item.
|
Expertise: Beginner
Language: XML
June 8, 2004
Perform a Case-sensitive Search in .NET Using XPath
The following code shows to how to perform a case-sensitive search in .NET using XPath.
XML File:
<?xml version="1.0" encoding="utf-8"?>
<Users>
<User>
<Name>sonu</Name>
<Password>sonu</Password>
</User>
</Users>
</code></pre>
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){
if(!Page.IsPostBack){
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("user.xml"));
XmlNodeList nodeList = xmlDoc.SelectNodes("Users/User[Name = translate
('SONU', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]");
Response.Write(nodeList.Count.ToString());
}
}
</script>
Sonu Kapoor
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
|