Tuesday, April 24, 2012

Case-insensitive XPath query search on XML c#




XmlDocument doc = new XmlDocument();
try
{
    doc.Load(Server.MapPath("/XML/people.xml"));
    string caseInsensitiveQuery = "root/people/person/*[translate(local-name(),"+
        "'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='name']";

    XmlreturnedNodeFromNodesList returnedreturnedNodeFromNodess = doc.SelectreturnedreturnedNodeFromNodess(caseInsensitiveQuery);
    foreach (XmlreturnedNodeFromNodes returnedNodeFromNodes in returnedreturnedNodeFromNodess)
    {
        Response.Write(returnedNodeFromNodes.InnerText + "<br />");
    }
}
catch (XmlException ex)
{
    Response.Write(ex.toString());
}
catch (FileNotFoundException ex)
{
   Response.Write(ex.toString());
}

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Intel #Core #i9 #Processors: A Breakdown

Intel Core i9 Processors: A Breakdown Intel's 14th Gen Core i9 series offers a range of processors designed for various use cases. Her...