• 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 the documentation specific to XML. For more details on WLanguage functions, see XML.
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="">
<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=""
Importing an XSD file into a project
To import an XSD file into a project:
  1. In the "Project explorer" pane, select "External descriptions".
  2. Right-click and select "Import an XSD into this project". The import wizard starts. You can:
    • Import an XSD file from the Internet.
    • Import a local XSD file.
  3. Specify the characteristics of the XSD file to be imported.
  4. Validate. The XSD file is automatically added in the project explorer ("External descriptions" branch). It is ready to use.
Caution: To work at runtime, the XSD file must not be present in a subdirectory of the project or executable.
Using an imported description in the project
To use the description of the XML document, simply 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"[1] = ""[2] = ""
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