Home | Sign in | English EN
  • Overview
  • Importing an XSD file into a project
  • Using an imported description in the project
  • Example: Full creation of a file according to the XSD description given in example:
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
WINDEV, WINDEV Mobile and WEBDEV include several functions for handling the XML code. The XML code used must comply with the XML standard. For more details, see a documentation specific to XML. See XML for more details.
WINDEV, WEBDEV and WINDEV Mobile allow you to import files in XSD format. An XSD file contains the description of the XML file of the same name. Knowing the structure of an XML document allows you to check the validity of this document. The description language for the content of an XSD document is also in XML format.
An example of XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
<xsd:element name="lastname" type="xsd:string"/>
<xsd:element name="firstname" type="xsd:string"/>
<xsd:element name="dob" type="xsd:date"/>
<xsd:element name="email" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
Followed by a valid XML file:
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Importing an XSD file into a project
To import an XSD file into a project:
  1. In the "Project explorer" pane, select "XML descriptions".
  2. Right click and select "Import an XML description file".
  3. Select the XSD file of the description to import.
  4. Validate. The XSD is automatically added into the project explorer (in the "XML description" branch). It is ready to use.
Caution: To operate at run time, the XSD file must not be found in a sub-directory of the project or in a sub-directory of the executable.
Using an imported description in the project
To use the description of the XML document, all you have to do is use the variables automatically generated by the import.
  1. Declare an XML document in the format of the imported description. For example, if the imported description is named 'person':
    cMyDoc is xmlDocument <description="person">

    Remark: You can specify the file extension during the declaration. For example:
    cMyDoc is xmlDocument <description="person.xsd">
  2. Initialize the different variables that are included in the description of the XML document. For example, if the document includes the last name and the first name of a person:
    cMyDoc.person.lastname = "MOORE"
    cMyDoc.person.firstname = "VINCE"

    • Each element is separated by a dot ..
    • A help is proposed when entering the names of variables.
    • If the name of an element contains a special character (dash for example), it must be enclosed in simple quotes:
      cMyDoc.person.'id-person' = "ValueId"
  3. Several functions can be used to handle the XSD file in order to validate the description of the XML file:
    XMLSaveSaves an XML document in a file.
    XMLValidDocumentValidates an XML document from an XSD schema.
    XMLValidNodeValidates an XML node, its children and its attributes from its description in the XSD schema linked to the XML document.

Example: Full creation of a file according to the XSD description given in example:

cMyDoc is xmlDocument <description="person.xsd">
cMyDoc.person.lastname = "Moore"
cMyDoc.person.firstname = "Vince"
cMyDoc.person.dob = "19710211"
cMyDoc.person.email[1] = "vince.moore@mydomain.com"
cMyDoc.person.email[2] = "vince.moore@otherdomain.com"
XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")
// Or with an intermediate check:
IF XMLValidDocument(cMyDoc) = True THEN
XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")
IF ErrorOccurred = True THEN
Error("Unable to save the XML document", ErrorInfo())
Info("OK", fExeDir() + ["\"] + "test.xml")
Error("The XML document is invalid", ErrorInfo())
Minimum version required
  • Version 15
This page is also available for…
Click [Add] to post a comment