PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
HImportXML (Function)
In French: HImporteXML
HFSQLHFSQL Client/ServerAvailable 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, HDeclareExternal or HDescribeFile).
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 22 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 22
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Versions 23 and later
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
New in version 23
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
Example
WINDEV
// Import the "C:\MyFiles\Customer.xml" file into the Customer file.
// The Customer file will be overwritten if it already exists (hImpCreation constant)
// A progress bar will be displayed in the PROGBAR_ProgBar1 control
HImportXML(Customer, "C:\MyFiles\Customer.xml", hImpCréation, PROGBAR_ProgBar1)
Syntax
<Result> = HImportXML(<File Name> [, <Path of XML File> [, <List of Destination Items> [, <List of 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.
<File Name>: Character string (with or without quotes)
Logical name of data file in HFSQL format into which the import will 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:
hImpNormal
(default value)
If the import data file already exists, it is filled with the imported data ; otherwise, the data file is created.
hImpCreationIf the import data file exists, it is overwritten.
hImpBreakableThe import can be interrupted by pressing the ESC key.
If the import is interrupted, the imported records are kept in the data file.
<Progress Bar>: Optional character string (with or without quotes)
  • Name of window where the progress bar will be displayed
  • Name of Progress Bar control that displays the progress.
WEBDEV - Server code This parameter is not available.
<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".
Remarks
WINDEVWEBDEV - Server codeAjaxHFSQLHFSQL 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 that is using 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.
Components
WINDEVWEBDEV - Server code wd230hf.dll
Linux wd230hf.so
Minimum required version
  • 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
Feb. 22 2017