XML Browser in C# Windows Form



Introduction:

In this article we will see how to show dataset data in XmlBrowser.

Background:

In this article I'm using the XmlBrowser control from a third party. This control will show the data of dataset in xml format and as well you can load any existing xml document. In a Windows form it's not easy to show xml data while in a web application browser; it only shows the content of the xml file.
Here I have just given this one sample example to show dataset data in xml format. I found this XmlRender.dll while doing a Google search. This XmlRender.dll file only contains the XmlBrowser control. We will see step by step how to show our data in xml format.

Step 1:

Create a new Windows Form application and add a reference to the XmlRender.dll.

Step 2:

Now that we have added a reference, now we can access the control in the XmlRender.dll file. Just create a new XmlBrowser control at runtime.

XmlRender.XmlBrowser xml=new XmlRender.XmlBrowser();

Set some properties of this XmlBrowser control now in Designer.cs page.

Step 3:

Now get your Dataset object and set the XmlBrowser's XmlText property to ds.GetXml() method which will display output as below.

xml.bmp

Conclusion:

Here we have seen use of the XmlBrowser control to show our data in xml format. You can show a XmlDocument also in this browser using the XmlBrowser.XmlDocument property.


Similar Articles