---
title: "Open and read an XML file to Dataset"  
description: "Open and read an XML file to Dataset"  
author: "Anonymous User"  
published: 2013-06-15  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1173/open-and-read-an-xml-file-to-dataset  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Open and read an XML file to Dataset

Hi MindStickians,\
How to Open and read an [XML file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php) to [Dataset](https://www.mindstick.com/articles/19/dataset)?\
Thanks in advance.\
\
\

## Replies

### Reply by Sumit Kesarwani

Hi Ashish, \
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();            ds.ReadXml(xmlFile);            int i = 0;            for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)            {                MessageBox.Show(ds.Tables[0].Rows[i].ItemArray[2].ToString());            }        }    }}
```


---

Original Source: https://www.mindstick.com/forum/1173/open-and-read-an-xml-file-to-dataset

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
