FormatType: DtXmlFormatType;
The FormatType property determines file structure format, according to which data is exported. By default format with fields as child nodes is used.
Executing the example requires that the repository contains an ETL task with the Etl identifier.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
XMLConsumer: IDtXmlConsumer;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxETLObject;
Begin
MB := MetabaseClass.Active;
//ETL task search. Repository object with the ETL identifier
MObj := MB.ItemById("Etl").Edit;
EtlTask := MObj As IEtlTask;
//Start of consumer creation
//Creation of the Export To XML object
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataXmlConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "XML_Consumer";
EtlConsumer.Name := "Export to XML";
EtlConsumer.Description := "Export to XML";
//Set up data consumer
XMLConsumer := EtlConsumer.Consumer As IDtXmlConsumer;
XMLConsumer.DataNodeName := "Row";
XMLConsumer.File := "c:\Data_out.Xml";
XMLConsumer.FormatType := DtXmlFormatType.FieldsAsAttributes;
XMLConsumer.RootNodeName := "Data";
//Save consumer
EtlConsumer.Save;
//End of consumer creation
//Start of visual object creation
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//End of visual object creation
//Save Etl task
MObj.Save;
End Sub Main;
After executing the example the Export to XML object is created in the ETL task. The consumer exports data into the XML file Data_out.xml. If the file does not exist it is created.
During export the file turns into:
<Data>
<Row Code="10" Country="Russia" Year="1990" Value="100.5" />
<Row Code="10" Country="Russia" Year="1991" Value="104.1" />
<Row Code="10" Country="Russia" Year="1992" Value="107.2" />
<Row Code="10" Country="Russia" Year="1993" Value="106.7" />
<Row Code="20" Country="France" Year="1990" Value="90.3" />
<Row Code="20" Country="France" Year="1991" Value="104.5" />
<Row Code="20" Country="France" Year="1992" Value="102.3" />
<Row Code="20" Country="France" Year="1993" Value="100.5" />
...
</Data>
See also: