---
title: "Open and Read XML file in C#"  
description: "Open and Read XML file in C#"  
author: "Anonymous User"  
published: 2013-06-15  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1170/open-and-read-xml-file-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Open and Read XML file in C#

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs),\
How can I open and read the [XML file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php) using C#?\
\

## Replies

### Reply by Sumit Kesarwani

Hi Chintoo,You can use this code:\

```
using System;using System.Data;using System.Windows.Forms;using System.Xml;using System.IO; namespace WindowsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }         private void button1_Click(object sender, EventArgs e)        {            XmlDataDocument xmldoc = new XmlDataDocument();            XmlNodeList xmlnode;            int i = 0;            string str = null;            FileStream fs = new FileStream("product.xml", FileMode.Open, FileAccess.Read);            xmldoc.Load(fs);            xmlnode = xmldoc.GetElementsByTagName("Product");            for (i = 0; i <= xmlnode.Count - 1; i++)            {                xmlnode[i].ChildNodes.Item(0).InnerText.Trim();                str = xmlnode[i].ChildNodes.Item(0).InnerText.Trim() + " | " + xmlnode[i].ChildNodes.Item(1).InnerText.Trim() + " | " + xmlnode[i].ChildNodes.Item(2).InnerText.Trim();                MessageBox.Show(str);            }        }    }}
```


---

Original Source: https://www.mindstick.com/forum/1170/open-and-read-xml-file-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
