FormatType: DtXmlFormatType;
The FormatType property determines file structure format, according to which data is imported. 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 and the Data.xml file in the root of the C disk.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
XMLProvider: IDtXMLProvider;
WxProvider: IWxRectangle;
WxETLProvider: IWxETLObject;
Begin
MB := MetabaseClass.Active;
// Search for ETL task. Repository object with the "ETL" identifier
MObj := MB.ItemById("ETL").Edit;
EtlTask := MObj As IEtlTask;
// Start of data provider creation
// Create the "Import from XML" object
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataXMLProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "XML_Provider";
EtlProvider.Name := "Import from XML";
EtlProvider.Description := "Import from XML";
// Set up data provider
XMLProvider := EtlProvider.Provider As IDtXMLProvider;
XMLProvider.File := "c:\Data.xml";
XMLProvider.FormatType := DtXmlFormatType.FieldsAsAttributes;
XMLProvider.XPath := "Data/Row[@Year > ""1991"" and @Year < ""1993""]";
XMLProvider.FieldsFromFile;
EtlProvider.FillDefault;
// Save data provider
EtlProvider.Save;
// End of data provider creation
// Start of visual object creation
WxProvider := EtlTask.Workspace.CreateRectangle;
WxETLProvider := New WxETLObject.Create;
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.Bottom;
WxProvider.Style.PictureMarginTop := -10;
WxProvider.PinPosition := New GxPointF.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
// End of visual object creation
// Save ETL task
MObj.Save;
End Sub UserProc;
After executing the example the Import from XML object is created in the ETL task. The data provider imports data from the specified XML file. Field values are taken from attribute values of the Row node. Only records with the Year attribute value in the range (1991;1993) are imported.
See also: