In french: HImporteXML
Available only with these kinds of connection
Imports an XML file into a data file in HFSQL Classic or Client/Server format (data file described in the data model editor, or declared by HDeclare
// Import "C:\MyFiles\Customer.xml" into Customer data file.
// The Customer data file will be overwritten if it already exists (hImpCreation constant)
// A progress bar will be displayed in PROGBAR_ProgBar1
HImportXML(Customer, "C:\MyFiles\Customer.xml", hImpCréation, PROGBAR_ProgBar1)
<Result> = HImportXML(<Data file> [, <Path of the XML file> , <Destination items> [, <XML attributes to import>]] [, <Options> [, <Progress Bar> [, <Root node>]]])
- True if the operation was performed,
- False if an error occurred. HError is used to identify the problem.
<Data file>: Character string
Name of the HFSQL data file into which the import must be performed.
<Path of the XML file>: Optional character string
Full access path to XML file to import.
<Destination items>: Optional character string
List of names of items in the data file into which the import will be performed. The names can be delimited by single quotes and they are separated by commas or CR characters. The names of the composite key items, binary memo items and binary items are ignored.
The non-imported items will be initialized with their default value described in the analysis.
If this parameter is not specified or if it corresponds to an empty string, all the items are imported (except the composite keys, the binary items and the binary memos) in the physical order of description.
<XML attributes to import>: Optional character string
List of names of items found in the XML file to import.
If this parameter is not specified or if it corresponds to an empty string, all the nodes of XML files are imported.
<Options>: Optional Integer constant (or combination of constants)
Configures the type of import to perform:
|hImpBreakable||The import can be interrupted by pressing the Esc key on the keyboard. |
If the import is interrupted, the imported records are kept in the data file.
|hImpCreation||If the import data file exists, it is overwritten.|
|If the import data file already exists, it is filled with the imported data ; otherwise, the data file is created.|
<Progress Bar>: Optional control or window name
- Name of the window in which the progress bar will be displayed
- Name of the Progress Bar control.
This parameter is not available.
<Root node>: Optional character string
Node of XML file from which the import will be performed. Used to import a section of XML file into the HFSQL data file. The type of this parameter is "root/clients".
Type of import
If the list of XML attributes is specified: the import will find the XML nodes with the same name as the items.
Example: The data file described in the analysis contains the following items: ITEM1, ITEM2; ... The XML file must have the following structure:
The names of nodes found in the XML file that do not exist in the analysis or that are not specified in the list of items will be ignored during the import.
If the list of XML attributes is not specified, the value of the XML nodes is included in the item of the HFSQL data file that is named like the XML attribute.
Example: The data file described in the analysis contains the following items: NODE1, NODE2, NODE3.
The XML file has the following type of structure and the list of specified items is "NODE2+NODE1":
'Data1' will be assigned to 'NODE2',
'Data2' will be assigned to 'NODE1'
'Data3' will be ignored because the list of items " NODE2+NODE1 " contains 2 items only.
HImportXML can also be used to import array items.
To do so, the array elements must be included in the child tags.
Example: The data file described in the analysis contains the following items: ITEM1, ITEM2, ARRAYITEM. The ARRAYITEM item is an array item.
The list of items is "ITEM1+ITEM2+ARRAYITEM" and the XML file has the following structure:
<!-- child tags -->
'Data1' will be assigned to 'ITEM1',
'Data2' will be assigned to 'ITEM2',
'ArrayData1' will be assigned to 'ARRAYITEM',
'ArrayData2' will be assigned to ARRAYITEM'.
Format of expected XML
HImportXML expects an XML file with a specific structure.
<racine><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
This format is also used by HExportXML
If your XML file does not use this structure, the import will not be performed properly. You may get one record per item for example.
Business / UI classification: Business Logic
This page is also available for…