---
title: "Filter in a XML file in C#"  
description: "Filter in a XML file in C#"  
author: "Manoj Bhatt"  
published: 2013-06-15  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1176/filter-in-a-xml-file-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Filter in a XML file in C#

Hi Experts,\

How to [filter](https://www.mindstick.com/interview/1717/what-is-css-filter) in a [XML](https://www.mindstick.com/blog/203/working-with-xml-data-in-sql-server) [file in C#](https://www.mindstick.com/forum/159903/how-to-create-a-log-file-in-c-sharp)?

Thanks in advance.

## Replies

### Reply by Sumit Kesarwani

Hi Manoj,\
The following code will solve your problem:\

```
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], "Product_price > = 3000", "Product_Name", DataViewRowState.CurrentRows);            dv.ToTable().WriteXml("Result.xml");            MessageBox.Show("Done");        }    }}
```


---

Original Source: https://www.mindstick.com/forum/1176/filter-in-a-xml-file-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
