# XML Binding

Get started with TreeView, a WinForms control to help users display a hierarchical item list. See more in documentation here.

## Content

With TreeView, you can easily load an XML document with relational data using the **ReadXML** method. The **ReadXML** method has the following overloads depending on the user requirement allowing them to load the TreeView from XML file, stream, text reader, XML document or XML reader:

| **Overloads** | **Description** |
| --------- | ----------- |
| **ReadXml(string fileName)** | Loads the TreeView from an Xml document, where the **fileName** parameter is the name of the file to be loaded, including the path. |
| **ReadXml(System.IO.Stream stream)** | Loads the TreeView from an Xml document, where the stream parameter is the **System.IO.Stream** object to be used for loading the TreeView. |
| **ReadXml(System.IO.TextReader tr)** | Loads the TreeView from an Xml document, where tr parameter is the **System.IO.TextReader** object to be used for loading the TreeView. |
| **ReadXml(System.Xml.XmlDocument doc)** | Loads the TreeView from an Xml document, where the doc parameter is the **System.Xml.XmlDocument** object to be used for loading the TreeView. |
| **ReadXml(System.Xml.XmlReader xr)** | Loads the TreeView from an Xml document, where the xr parameter is the **System.Xml.XmlReader** object to be used for loading the TreeView. |

The following example shows how to use the **ReadXML** method to load TreeView from an XML document using the XML DataSource.

```csharp
//loads a TreeView compatible XML file (Xml exported using WriteXML of C1TreeView)
private void LoadXml()
{
    ClearTreeView();
    c1TreeView1.ReadXml("SimpleTree.xml");
}
```

You can further save the contents of the TreeView to an XML document using the **WriteXml** method.

>type=note
> Note that XML import/export works only with the files saved with C1TreeView.