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
  • Special cases
  • Code wizard
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Returns the value of an XML element or the value of the attribute for an XML element.
Example
MonDoc is string = fLoadText("exemple.xml")
XMLDocument("DOM", MonDoc)
sNomFonction is string = XMLRead("DOM","/Exemple/Aide/Fonction")
sTypeFonction is string = XMLRead("DOM","Aide/Fonction/@type")
sNomFonction2 is string = XMLRead("DOM","Aide/Fonction[2]")
sImage is string = XMLRead("DOM","Aide[2]/@image")
sTypeImage is string = XMLRead("DOM","/Exemple/Aide[@image=""trait.jpg""]/@format", "NonDefini")
XMLClose("DOM")
// S'applique au document XML suivant:
// <Exemple>
// <Aide>
// <Fonction type="1">Lire</Fonction>
// <Fonction>Ecrire</Fonction>
// </Aide>
// <Aide image="trait.jpg" format="jpg" />
// </Exemple>
Syntax
<Result> = XMLRead(<XML document> , <Path of the element to be read> [, <Not found>])
<Result>: Character string
  • Value of element or value of attribute,
  • Empty string ("") or value of <Not found> parameter in the following cases:
    • if the element was not found.
    • if the element has no value
    • if the XPath query is not a query for selecting records.
      In this case, the ErrorOccurred variable is set to True and ErrorInfo returns more details about the error.
<XML document>: Character string
Name of XML document where the reading will be performed. This document contains the XML code to study and it was created by XMLDocument.
<Path of the element to be read>: Character string
Can correspond to:
  • the path of the value to read in the XML file. Please note: case is taken into account (upper and lower case).. To read the value of an attribute, the name of the attribute must be preceded by the "@" character.
  • the text of an XPath query to run. The XPath query must be a query for "selecting records". If several elements match the selection, the first element found is used.
If this path does not start with "/", the name of the root node is automatically added. If the XML document has no root, <Result> will correspond to <Not found>.
<Not found>: Optional character string
Text to return if the element was not found. This parameter corresponds to an empty string ("") by default.
Remarks

Special cases

  • XMLRead does not modify the current position in the document.
  • Several XML browse queries cannot be nested.
  • XMLRead must not be used with an XMLDocument variable. To read the content of an XMLDocument variable, use the "FOR EACH" syntax.
WINDEVWEBDEV - Server codeWINDEV Mobile

Code wizard

The code editor includes a code wizard to generate the code of XMLRead. To use it, type "XMLRead(" in the code editor and select "Wizard for XMLRead".
Business / UI classification: Business Logic
Component: wd300xml.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help