ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / XML file functions
  • Managing the addition
  • Saving the modifications in the XML file
  • XML functions and threads
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
XMLAddChild (Function)
In french: XMLAjouteFils
Adds a child tag into an XML document. This child tag is added at the end of list of attributes for the current position.
// Ajout d'une nouvelle ligne de commande
XMLParent("CdeXML")
XMLAddChild("CdeXML", "lignecommande", "", True)
XMLAddAttribute("CdeXML", "numero", "2")

// Ajout de la balise "codeproduit"
XMLAddChild("CdeXML", "codeproduit", "sro2125")

// Ajout de la balise "designation"
XMLAddChild("CdeXML", "designation", "souris optique")

// Ajout de la balise "quantité"
XMLAddChild("CdeXML", "quantité", "15")
Syntax
XMLAddChild(<XML document> , <Tag> [, <Tag value> [, <Change of position> [, <Option>]]])
<XML document>: Character string
Name of the XML document into which the addition must be performed. This document contains the XML code and it was created by XMLDocument.
<Tag>: Character string
Name of tag to add.
If this parameter corresponds to the CDATA constant, the content of the CDATA tag will not be interpreted by the XML parser. You have the ability to include an image in binary format in this tag. Please note: the encoding used must respect the encoding of the XML document.
AndroidAndroid Widget Please note: It is not possible to create elements (tags or attributes) with accented characters.
<Tag value>: Optional character string
Value of new tag. This parameter corresponds to an empty string by default.
<Change of position>: Optional boolean
  • True to be positioned on the added element. In this case, the added element becomes the current position.
  • False (default) to avoid modifying the current position during the addition.
<Option>: Optional Integer constant
Addition options. The possible values are:
XMLEncodingAmpersandIf the "&" character (ampersand) is found in the value of added tag, it will be encoded in "&amp;" format.
If this constant is not specified, the "&" character must be encoded in the XML tag. No encoding will be performed.
Remarks

Managing the addition

  • If the current position is an attribute, the new tag is added at the end of the current list of child tags for the tag that contains the attribute.
  • The current position in the document does not change during the call to XMLAddChild except if <Change of position> is set to True.
Note: The XMLDocument function does not create a document root.. To create a first child element in an empty document, this document must necessarily contain a root.

Saving the modifications in the XML file

To save the modifications performed in an XML file, you must:
  1. Use the XMLBuildString function. This function retrieves and formats the content of an XML document.
  2. Save the character string generated by XMLBuildString in an XML file. To do so, use the fSaveText function.
Example:
// Après modification du document XML 
SourceXML = XMLBuildString("DocXML")
// Enregistrement du fichier XML
fSaveText("ExampleModifié.xml", SourceXML)
WEBDEV - Browser code This feature is not available.

XML functions and threads

If your application uses threads, the XML document is shared between all these threads. For more details on threads, see Managing threads.
Component: wd300xml.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help