ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Type of import
  • Array items
  • Format of expected XML
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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, HDeclareExternal or HDescribeFile).
Example
WINDEV
// 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)
Syntax
<Result> = HImportXML(<Data file> [, <Path of the XML file> , <Destination items> [, <XML attributes to import>]] [, <Options> [, <Progress Bar> [, <Root node>]]])
<Result>: Boolean
  • 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:
hImpBreakableThe 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.
hImpCreationIf the import data file exists, it is overwritten.
hImpNormal
(default value)
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.
WEBDEV - Server code 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".
Remarks
WINDEVWEBDEV - Server codeAjaxHFSQL ClassicHFSQL Client/ServerStored procedures

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:
<FILE>
<ITEM1>Data1</ITEM1>
<ITEM2>Data2</ITEM2>
...
</FILE>
<FILE>
...
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":
<ELEMENT1>
<NODE1>Data1</NODE1>
<NODE2>Data2</NODE2>
<NODE3>Data3</NODE3>
...
</ELEMENT1>
<ELEMENT2>...
'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.

Array items

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:
<FILE>
<ITEM1>Data1</ITEM1>
<ITEM2>Data2</ITEM2>
<ARRITEM>
<!-- child tags -->
<ARRAYITEM_1>ArrayData1</ARRAYITEM_1>
<ARRAYITEM_2>ArrayData2</ARRAYITEM_2>
</ARRITEM>
</FILE>
...
'Data1' will be assigned to 'ITEM1',
'Data2' will be assigned to 'ITEM2',
'ArrayData1' will be assigned to 'ARRAYITEM[1]',
'ArrayData2' will be assigned to ARRAYITEM[2]'.

Format of expected XML

HImportXML expects an XML file with a specific structure.
Example:
<racine><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<record>
<item1>val</item1>
<item2>val</item2>
</record>
<record>
<item1>val</item1>
<item2>val</item2>
</record>
</root>
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
Component: wd290hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Not understandable
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"?>
<FormatDescription>
<Format>
<FormatId></FormatId>
<Description></Description>
<Name></Name>
<StandardType></StandardType>
<Importable></Importable>
<Exportable></Exportable>
<DataCategory></DataCategory>
<GroupSeperator />
<DecimalSeperator>,</DecimalSeperator>
<DateFormatExpression>TTMM</DateFormatExpression>
<DateFormatSeperator />
<CurrencySignExpression />
<DirectoryName />
<FileName />
<Version></Version>
<IsDefaultFormat></IsDefaultFormat>
<DataExtendedZone></DataExtendedZone>
</Format>
<Field>
<FieldId>1</FieldId>
<DisplayGroupId>106</DisplayGroupId>
<OrdinalNumber>0</OrdinalNumber>
<Label>DATEV-Format-KZ</Label>
<LabelAlias />
<Importable>1</Importable>
<Exportable>1</Exportable>
<Length>4</Length>
<DecimalPlaces>0</DecimalPlaces>
<FormatType>Text</FormatType>
<Necessary>1</Necessary>
<IsFormatable>0</IsFormatable>
<DecimalsEditable>0</DecimalsEditable>
<GroupingSymbol>1</GroupingSymbol>
<CreditDebitSign>0</CreditDebitSign>
<BaseFieldId>351</BaseFieldId>
<FixedLength>4</FixedLength>
<AddCreditDebitSign>0</AddCreditDebitSign>
<MaxCount>0</MaxCount>
</Field>
<Field>
<FieldId>2</FieldId>
<DisplayGroupId>106</DisplayGroupId>
<OrdinalNumber>1</OrdinalNumber>
<Label>Versionsnummer</Label>
<LabelAlias />
<Importable>1</Importable>
<Exportable>1</Exportable>
<Length>3</Length>
<DecimalPlaces>0</DecimalPlaces>
<FormatType>Zahl</FormatType>
<Necessary>1</Necessary>
<IsFormatable>0</IsFormatable>
<DecimalsEditable>0</DecimalsEditable>
<GroupingSymbol>0</GroupingSymbol>
<CreditDebitSign>0</CreditDebitSign>
<BaseFieldId>352</BaseFieldId>
<FixedLength>1</FixedLength>
<AddCreditDebitSign>0</AddCreditDebitSign>
<MaxCount>0</MaxCount>
</Field>

</FormatDescription>

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?
Friedrich
22 Feb. 2017

Last update: 07/03/2023

Send a report | Local help