There may be times when an object you are working with returns an XmlDocument object that you would like to bind to a server control such as a DataGrid. Because an XmlDocument cannot be bound directly what can you do?

The answer to this question lies in the XmlNodeReader. In this example you will see how to convert an XmlDocument to a DataSet in an efficient manner (as opposed to converting the XmlDocument to a string first) by using the XmlNodeReader class.

Code Here!!

          XmlDocument doc = new XmlDocument();
            doc.Load(Server.MapPath("Orders.xml"));
            XmlNodeReader reader = new XmlNodeReader(doc);
            DataSet ds = new DataSet();
            ds.ReadXml(reader);
            reader.Close();
            dg.DataSource = ds.Tables[0].DefaultView;
            dg.DataBind();