Class XmlDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Provides an XML-based data provider implementation that parses XML documents and exposes their data as tables and relations.
[Serializable]
public sealed class XmlDataProvider : IDataProvider, ICanHandleUsedIdentifiers, ISerializable, IFileList
- Inheritance
-
XmlDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the XmlDataProvider:
// Load an XML document from file.
XPathDocument myDoc = new XPathDocument(@"c:\users\public\data.xml");
// Create an XmlDataProvider using the loaded document.
XmlDataProvider provider = new XmlDataProvider(myDoc);
// Assign the provider as the data source for the List & Label reporting engine.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
listLabel.Export(exportConfiguration);
Remarks
The XmlDataProvider supports parsing of XML documents using XPath and exposes the underlying data structure to reporting engines. It supports both flat and hierarchical structures and provides options to flatten the structure and register empty nodes as columns.
Constructors
XmlDataProvider()
Initializes a new instance of the XmlDataProvider class.
public XmlDataProvider()
XmlDataProvider(string, ProvideXPathDocument?)
Initializes a new instance of the XmlDataProvider class with the specified URI.
public XmlDataProvider(string uri, XmlDataProvider.ProvideXPathDocument? provideXPathDocument = null)
Parameters
uristringThe URI of the XML document.
provideXPathDocumentXmlDataProvider.ProvideXPathDocumentAn optional callback to provide an XPath document.
XmlDataProvider(IXPathNavigable)
Initializes a new instance of the XmlDataProvider class with the specified document.
public XmlDataProvider(IXPathNavigable document)
Parameters
documentIXPathNavigableAn object that implements IXPathNavigable representing the XML document.
Properties
AutoResolveNamespacesMode
Gets or sets the mode used to automatically resolve XML namespaces.
public AutoResolveNamespacesMode AutoResolveNamespacesMode { get; set; }
Property Value
Document
Gets or sets the XML document to be parsed.
public IXPathNavigable Document { get; set; }
Property Value
FlattenNodesWithNoAttributes
Gets or sets a value indicating whether nodes with no attributes should be flattened.
public bool FlattenNodesWithNoAttributes { get; set; }
Property Value
FlattenStructure
Gets or sets a value indicating whether the XML structure should be flattened.
public bool FlattenStructure { get; set; }
Property Value
ParseFirstElementOnly
Gets or sets a value indicating whether only the first element in the XML file should be parsed.
When set to true, only the first element is parsed which may boost performance.
public bool ParseFirstElementOnly { get; set; }
Property Value
RegisterEmptyNodesAsColumnsWhenFlattening
When FlattenStructure is enabled, this property determines whether empty XML nodes are registered as columns.
If set to true, empty XML nodes will be registered as columns even when flattening is enabled.
public bool RegisterEmptyNodesAsColumnsWhenFlattening { get; set; }
Property Value
Uri
Gets or sets the URI of the XML document to be parsed. Setting this property resets the current document and marks all tables as volatile.
public string Uri { get; set; }
Property Value
ValueFieldName
Gets or sets the field name to be used for the value of XML elements that have attributes.
For example, in <item unit="Dollar">17</item>, the field name for the content "17" will be value.
public string ValueFieldName { get; set; }
Property Value
Events
GetNodeType
Occurs when determining the node type during XML parsing. Subscribers can override the default node type determination.
public event EventHandler<GetNodeTypeEventArgs> GetNodeType
Event Type
PreParseXPathNavigator
Occurs before parsing an XPathNavigator. This event allows custom handling or overriding of the parsing process.
public event EventHandler<PreParseXPathNavigatorEventArgs> PreParseXPathNavigator