---
title: "Search in a XML file in C#"  
description: "Search in a XML file in C#"  
author: "Anonymous User"  
published: 2013-06-15  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1175/search-in-a-xml-file-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Search in a XML file in C#

Hi Experts,\
How to [Search](https://www.mindstick.com/articles/65368/best-smo-services-company-in-hyderabad-improve-search-rankings) in a [XML file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php)?\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Sumit Kesarwani

Hi Jeet,\
You can use this code:\

```
using System;using System.Data;using System.Windows.Forms;using System.Xml; namespace WindowsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }         private void button1_Click(object sender, EventArgs e)        {            XmlReader xmlFile;            xmlFile = XmlReader.Create("Product.xml", new XmlReaderSettings());            DataSet ds = new DataSet();            DataView dv;            ds.ReadXml(xmlFile);             dv = new DataView(ds.Tables[0]);            dv.Sort = "Product_Name";            int index = dv.Find("Product2");             if (index == -1)            {                MessageBox.Show("Item Not Found");            }            else            {                MessageBox.Show(dv[index]["Product_Name"].ToString() + " " + dv[index]["Product_Price"].ToString());             }        }    }}
```


---

Original Source: https://www.mindstick.com/forum/1175/search-in-a-xml-file-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
