Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy Data and Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Binding Controls to XML Data

This document explains how to display data from an XML file in a data-aware control.

Expanded Binding to XML Data

To bind a control to XML data, you need to create a DataSet object. This object provides methods that let you load XML files, streams containing XML data, etc. After data has been loaded into a DataSet, you can initialize the control's DataSource property with a table from that DataSet or the table's bound data view. Alternatively, you can set the DataSource and DataMember properties to the DataSet and the desired table name.

The image below illustrates binding to XML data.

An XML schema describes the type of data stored in an XML file. The schema can be stored along with data in a single XML file or in an external (.XSD) file. When data is loaded using DataSet methods, you must ensure that the schema is loaded as well. Otherwise, all loaded data will be treated as text and this can cause certain issues (such as editors not being assigned to columns in Grid Control depending upon the type of data, summaries will not be calculated in the PivotGrid control, etc.).

When a control is bound to XML data, changing cell values does not update the data source. Data changes are actually applied to the DataSet where the data was loaded. To apply changes to the data source, use the methods provided by the DataSet class. For instance, if data has been loaded from an XML file using the ReadXML method, you need to call the WriteXML method to overwrite the original file.

Note that binding to XML data can only be done at runtime. Specific controls, however, (e.g. Grid Control and XtraPivotGrid) let you preview data at design time via their Layout designer page.

Expanded See Also

How would you rate this topic?​​​​​​​