- Type of import
- Array items
- Format of expected XML
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
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
// Import of the file "C:\MyFiles\Client.xml" into the data file Client.
// If the data file Client exists, this data file will be overwritten (constant hImpCreation)
// A progress bar will be displayed in the PROGBAR_ProgBar1 control
HImportXML(Customer, "C:\MyFiles\Customer.xml", hImpCreation, PROGBAR_ProgBar1)
<Result> = HImportXML(<Data file> [, <Path of XML file> [, <List of destination items> [, <List of 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 (with or without quotes)
Name of the data file in HFSQL format in which the import is to be performed.
<Path of XML file>: Optional character string (with quotes)
Full access path to XML file to import.
<List of destination items>: Optional character string (with quotes)
List of names of items 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.
<List of XML attributes to import>: Optional character string (with quotes)
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:
|If the import data file already exists, it is filled with the imported data ; otherwise, the data file is created.|
|hImpCreation||If the import data file exists, it is overwritten.|
|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.
<Progress Bar>: Optional field or window name
- Name of window where the progress bar will be displayed
- Name of Progress Bar control that displays the progress.
<Root node>: Optional character string (with quotes)
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',
TabData1' will be assigned to'RUBTABLEAU[ 1]',
"TabData2" will be assigned to"RUBTABLEAU[ 2]".
Format of expected XML
HImportXML expects an XML file that is using 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 / GUI classification : Business Logic
This page is also available for…
I'm afraid the documentation is insufficient. The expected Format and usage is not clear. So I have an example for you:
This is the XML Code
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
Now I want to Import the struff in Format into one DataFile and Field stuff into naother. I tried a lot of things with the root node. What happens acutall with this Code:
HImportXML(DatevFieldDescription,"c:\temp\test2.xml ", "", "",hImpCreation, PROGBAR_ImportFromXML)
The stuff below Format is emported with the fields set to some default values.
So how am I supposed to use HImportXML to get just parts from the XML-file?