Skip to main content

XML Data

  • 2 minutes to read

The Data Source Configuration Wizard allows you to bind the PivotGridControl to XML files created using the DataSet.WriteXML method (see Binding Controls to XML Data). This topic guides your through the stesps needed to do this.

  1. Click the Data Source Wizard button placed on the PivotGridControl or use the corresponding command in the control’s smart tag.

    WinPivot_DataSourceButton

  2. In the invoked Data Source Configuration Wizard, select XML Data

    DataSourceConfigurationWizard_SelectXML

    … and click Next.

  3. On the next page, select the required binding method and click Next.

    DataSourceConfigurationWizard_XML_Page2

  4. On the final page, specify the following settings.

    DataSourceConfigurationWizard_XML_Finish

    • Xml Data Path - Specifies the path to the required XML data file manually or click the Load Xml… button and locate the file.
    • Table - Specifies a data table.

    Click Finish.

  5. The following code will be generated by the Data Source Configuration Wizard.

    public Form1()
            {
                InitializeComponent();
                // This line of code is generated by Data Source Configuration Wizard
                // Create a new DataSet
                System.Data.DataSet xmlDataSet = new System.Data.DataSet("XML DataSet");
                // Load the XML document to the DataSet
                xmlDataSet.ReadXml(@"C:\temp\WebsiteStatisticsData.xml");
                // This line of code is generated by Data Source Configuration Wizard
                pivotGridControl1.DataSource = xmlDataSet.Tables["Data"];
            }
    

    You can work now with the created data source at runtime. For instance, to retrieve fields from the connected data source, call the PivotGridControl.RetrieveFields method.