ActiveReports 11
XML
ActiveReports 11 > ActiveReports User Guide > Samples and Walkthroughs > Samples > Section Report > Data > XML

The XML sample displays customer order list using the XML data source. The sample demonstrates how to create a report with XML data, using a SubReport or using the XML hierarchical structure.

Sample Location

Visual Basic.NET

<User Folder>\Documents\GrapeCity Samples\ActiveReports 11\Section Reports\Data\XML\VB.NET

C#

<User Folder>\Documents\GrapeCity Samples\ActiveReports 11\Section Reports\Data\XML\C#

Run-Time Features

When you run the sample, you will be asked to select between the following.

Run Customers XML Report
Demonstrates a two level Master/Detail XML Data Source. Uses a SubReport to print the orders of each customer. By selecting any of the radio buttons - Show All Data, Show Report where ID = 2301, or Show All Data with an E-Mail address, you can change the creation option of the generated report. 

Customer Orders (Leveled)
Displays customer's orders by using the XML hierarchical structure. The Master/Detail is implemented using the XML hierarchy XPath selection patterns without any SubReports.

Project Details

StartForm

This is the main form of the sample. You see this form after you run the project and where you can select how to display XML data.

  • Run Customers XML Report
    Displays the customers order list by using SubReports.To bind the CustomersOrders report to the XML data source, the valid XPath expression is entered in the RecordsetPattern field on the XML tab of the Report Data Source dialog.  
  • Customer Orders (Leveled)
    Displays customer's orders by using the XML hierarchical structure, which is demonstrated by the OrdersLeveled report. To bind this report to XML data, the path to the XML file is entered in the File URL field on the XML tab of the Report Data Source dialog and also the XML hierarchical structure like "../../@email" is specified in each field. 

CustomersOrders report

This report embeds the srptOrders SubReport. Following settings are performed in this report. 

  • Embed the SubReport control
    Places the SubReport control in the Detail section and connects it to the Orders SubReport for displaying the orders list.

OrderItems SubReport

This report binds to the Subreport control of Orders report.

Orders SubReport

This is the report with a SubReport control that is bound to the OrderItems report.  Following settings are performed in this report.

  • Embed the SubReport control
    Places the SubReport control in the Detail section and connects it to the OrderItems report for displaying the list of orders.
    The Report property of the Subreport control is specified in the Orders_ReportStart event.
  • Set the XML data source included in the SubReport
    Indicates a method to retrieve the record set using the NodeList property instead of the RecordsetPattern property of the XML data source on OrderItems report at design time.
    The NodeList property of the XML data source is set in the Detail_Format event.

OrdersLeveled report

Displays the list of customer's orders. Following settings are performed in this report.

  • Groups data
    Groups data using the XPath pattern that represents the hierarchical structure of XML. DataField property of ghCustomers section and ghOrders section is set at design time.

ViewerForm

The Viewer control has its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time. Right-click the form and select View Code to see the code used to run the report and display it in the viewer.

See Also

How To

Concepts