Skip to content

ImportFromXml

Imports xml data to specified table. If record already exist in table it's updates existing. If no record exist a new record added to table. Comparison automatically done with table primary key.

1
myDataTable.ImportFromXml(options: QueryWithMappings):DataTable

Parameters

QueryWithMappings options
    Specifies the import options and may contain one or more following properties:

Remarks

ColumnsXPath is used to specify additional secondary mapping path by XPath argument.
This method does not call save method after execuiton. If you want to save changes, you need to explicitly call Save method or use $Database.ImportFromXml instead.

Common use for importing data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
var table = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'Groups'
    }
});

table.ImportFromXml({
    XPath : 'Groups/Group'
});

table.Save();

Using map function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var table = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'Groups'
    }
});

table.ImportFromXml({
    XPath : 'Groups/Group',
    map : function (node) {
        this.Id = node.Evaluate('../Id');
    }
});

table.Save();

Types

QueryWithMappings

Columns : Array<QueryColumn>
Array of columns

Map : (node: Xml) => void

MaxLength : number
Maximum number of rows. If not set all rows are returns.

Node : Xml
Root node of mapping. If not specified $Xml instance is used.

Order : Array<QueryOrder>
Array of order columns

Parameters : object
Additional parameters

Start : number
Start index of rows.

SubQueries : Array<SubQuery>
Array of sub queries.

TargetSchema : string
Name of schema to execute query on.

TargetTable : string
Name of table to execute query on.

Where : QueryBlock
Criteria of query

XPath : string
Root xpath to be mapped.

QueryColumn

Defines a query column to included in result

Expression : string
Expression of column.

Name : string
Name of column to use in results. If not specified expression is used.

XPath : string
XPath to be mapped.

QueryOrder

Defines order expression of query result

Expression : string
Expression to order.

Type : ( "Ascending" | "Descending" )
Type of ordering. If not specified Ascending is used.

SubQuery

Columns : Array<QueryColumn>
Array of columns

MaxLength : number
Maximum number of rows. If not set all rows are returns.

Name : string
Name of sub query. Relation name can be used as name.

Order : Array<QueryOrder>
Array of order columns

Parameters : object
Additional parameters

Relation : string
Name of relation

Start : number
Start index of rows.

SubQueries : Array<SubQuery>
Array of sub queries.

TargetSchema : string
Name of schema to execute query on.

TargetTable : string
Name of table to execute query on.

Where : QueryBlock
Criteria of query

XPath : string
Specifies the target xpath to export data on.

QueryBlock

Blocks : Array<QueryBlock>
Array of criteria blocks

Condition : ( "And" | "Or" )
Condition with next block. If not specified And value is used.

Criteria : Array<QueryCriteria>
Array of criteria

QueryCriteria

Defines a criteria to be used to filter results

Comparison : ( "Equals" | "Different" | "LessThan" | "GreaterThan" | "LessThanOrEqualTo" | "GreaterThanOrEqualTo" | "Like" )
Comparison operator. Default value is Equals.

Condition : ( "And" | "Or" )
Condition with next criteria. If not specified And value is used.

Expression : string
Criteria expression.

IgnoredValues : any
Array of ignored values.

Value : any
Value or Expression to compare

ValueType : ( "Direct" | "Expression" )
Type of value. If not specified Direct value is used.

See Also