Help / WLanguage / WLanguage functions / Standard functions / XML file functions
  • Overview
  • Definition
  • Principle
  • Two methods
  • Using an xmlDocument variable
  • Using a string variable
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 XML code. The XML code used must comply with the XML standard. See a documentation specific to XML for more details.
The XML code is used for example:
XML is a language containing tags and attributes (called "elements" in this help).
The structure of an XML code corresponds to a tree structure: the information is organized hierarchically.
The following terms are used to describe the different parts of an XML code:

XML vocabulary center

XML code (or content) corresponds to:
  • the content of an XML file.
  • a response from an XML web service.
The XML functions allow you to:
  • read, find and analyze the content of an XML file.
  • modify the content of an XML file.
  • format the content of an XML file.
  • run an XPATH query in the content of an XML file.
  • analyze the responses received from the XML Webservices.
  • import data (HImportXML).

Two methods

Two methods can be used to handle an XML document:
  1. Using an xmlDocument variable (Recommended method). This method allows you to use a XSD file.
  2. Using a string variable to store the XML document. Then, the XML document can be handled by the different XML functions.

Using an xmlDocument variable

The xmlDocument variables can be declared by indicating a sample document (XML file) or a template document (XSD file). The structure of this document will be read by WINDEV, WEBDEV and WINDEV Mobile. Therefore, the automatic completion will be available for the names of nodes in the code editor.
To declare an xmlDocument variable with a sample document:
  1. Add the XML document into the project via one of the following methods:
    • on the "Project" tab, in the "Project" group, expand " List of elements" and click "List of project elements". The list of project elements is displayed. Click the "Add" button and select the XML document.
    • drag the file and drop it in the "External descriptions" folder of the "Project explorer" pane.
    • in the "Project explorer" pane, select the "External descriptions" folder, then:
      • "Import an XML or JSON into this project" in the context menu.
      • "Import an XSD into this project" in the context menu.
  2. The XML document appears in the "External descriptions" folder of the project explorer. You have the ability to see its structure.
  3. Declare the variable as follows:
    <Variable name> is xmlDocument, description =  <Document name>

    <Document name> can correspond to the name of sample document (with or without extension) or to the name of template document (with or without extension).
    • This declaration can be obtained automatically by "dropping" the name of the XML document directly from the "Project Explorer" pane.
    • When using a sample document, you also have the ability to use the following syntax:
      <Variable name> is xmlDocument
      <Variable name> = XMLOpen(<Document name>)
  4. You can directly access the variable nodes by their names. These names are automatically proposed by the automatic completion mechanism of the code editor.
Remark: XMLSave is used to save the XML document. If an XSD file was used, it will be automatically taken into account.

Using a string variable

To handle an XML code:
  1. Store the XML code in a string variable (fLoadText). This code can come from an XML file or from an XML Web service.
  2. Create an XML document (XMLDocument). This document is stored in memory and contains the entire XML code to use.
  3. Handle your XML document with the WLanguage functions. You can:
  4. Save the modifications if necessary (XMLBuildString and fSaveText).
  5. Close the XML document (XMLClose).
Remark: You also have the ability to create an XML document:
Related Examples:
Reading and writing in XML format Unit examples (WINDEV): Reading and writing in XML format
[ + ] Using the XMLxxx functions to:
- Create an XML document
- Read an XML document
XML parser Unit examples (WINDEV): XML parser
[ + ] Studying the content of an XML file via the XMLxxx functions of WINDEV
WD Syntactic Coloring Training (WINDEV): WD Syntactic Coloring
[ + ] This example proposes a base class used to perform a standard syntax highlighting on some text.
This highlighting is based on a rough analysis of the lemmes found in a text in order to identify the elements of a programming language for instance.
It can be overridden or derived in order to customize the system and the highlighting language.
This example is used to highlight SQL code and XML code but it can be extended to highlight other languages or other text formats.
WD Multimedia Complete examples (WINDEV): WD Multimedia
[ + ] This example shows how to play animations, audio and video files (MP3, WAV, AVI, MPEG, etc.) using the Multimedia control in WINDEV.
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment

Last update: 02/07/2024

Send a report | Local help