# XML Export

ActiveReports offers several options to control how reports render to XML. You can even control XML output through properties on individual report controls.

## Content

XML is a useful format for delivering data to other applications as the resulting XML file opens in an internet browser. You can use the [XmlRenderingExtension](/activereportsnet/api/v20.1/MESCIUS.ActiveReports.Export.Xml/GrapeCity.ActiveReports.Export.Xml.Page.XmlRenderingExtension.html) to render your report in this format. XML is a good format for delivering data to other applications. The resulting XML file opens in an internet browser.

## Xml Rendering Properties

ActiveReports offers several options to control how reports render to XML.

| Property | Description |
| -------- | ----------- |
| [Encoding](/activereportsnet/api/v20.1/MESCIUS.ActiveReports.Export.Xml/GrapeCity.ActiveReports.Export.Xml.Page.Settings.html) | Select the encoding schema to use in the XML transformation. |
| [XslStylesheet](/activereportsnet/api/v20.1/MESCIUS.ActiveReports.Export.Xml/GrapeCity.ActiveReports.Export.Xml.Page.Settings.html) | Select the existing XSL Stylesheet file to use to transform the resulting XML file. **Note**: When using the XslStylesheet option, be sure to save the file in the correct file format, such as HTML. |

## Controlling XML Output

You can also control XML output through properties on the individual report controls. These properties are:

* **DataElementName** Indicates the name to use for the data element or attribute.
* **DataElementOutput** Indicates whether the report controls render in the XML output.
* **DataElementStyle** Indicates whether a text box renders as an element or an attribute.
* **DetailDataCollectionName** Indicates the name to use for the collection of all instances of the detail group in the XML output.
* **DetailDataElementName** Indicates the name to use for instances of the detail group in the XML output.
* **DetailDataElementOutput** Indicates whether the details appear in the XML output.
* **DataInstanceElementOutput** Indicates whether a list appears in the XML output. (This property is ignored if there is a grouping in the list.)
* **DataInstanceName** Indicates the name to use for instances of the list in the XML output.

## Interactivity

XML format does not support interactive features except that when rendering a report to XML, complete drill-down data is shown regardless of whether the data is rendered in an expanded state or not.

## Export Report using XML Rendering Extension

The following steps provide an example of rendering a report in XML format.

1. Create a new or open an existing Windows Forms App in Visual Studio project.
2. Go to the Project Explorer, right-click the project and select **Add** \> **New Item.**
3. Select **ActiveReports 20 Standalone Report** \> **Add** and choose a report type, **RDLX**, **RDLX Dashboard**, or **Page** report and then click **Finish**.
4. Add a reference to **MESCIUS.ActiveReports.Export.Xml** package in the project.
5. On the Form.cs or Form.vb that opens, double-click the title bar to create the Form\_Load event.
6. Add the following code inside the Form\_Load event.

```vbnet
' Provide the Page report you want to render.

Dim rptPath As New IO.FileInfo("..\..\..\Report1.rdlx")

Dim pageReport As New GrapeCity.ActiveReports.PageReport(rptPath)

' Create an output directory.
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyXml")
outputDirectory.Create()

' Provide settings for your rendering output.
Dim xmlSetting As New GrapeCity.ActiveReports.Export.Xml.Page.Settings()
Dim setting As GrapeCity.ActiveReports.Extensibility.Rendering.ISettings = xmlSetting

' Set the rendering extension and render the report.
Dim xmlRenderingExtension As New GrapeCity.ActiveReports.Export.Xml.Page.XmlRenderingExtension()

Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))

' Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = True

pageReport.Document.Render(xmlRenderingExtension, outputProvider, xmlSetting)
```

```csharp
// Provide the Page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\..\Report1.rdlx");

GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyXml");
outputDirectory.Create();

// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Xml.Page.Settings xmlSetting = new GrapeCity.ActiveReports.Export.Xml.Page.Settings();
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = xmlSetting;

// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Xml.Page.XmlRenderingExtension xmlRenderingExtension = new GrapeCity.ActiveReports.Export.Xml.Page.XmlRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));

// Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = true;

pageReport.Document.Render(xmlRenderingExtension, outputProvider, xmlSetting);
```