PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Special cases
  • Code wizard
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Returns the value of an XML element or the value of the attribute for an XML element.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
MyDoc is string = fLoadText("example.xml")
XMLDocument("DOM", MyDoc)
sFunctionName is string = XMLRead("DOM","/Example/Help/Function")
sFunctionType is string = XMLRead("DOM","Help/Function/@type")
sFunctionName2 is string = XMLRead("DOM","Help/Function[2]")
sImage is string = XMLRead("DOM","Help[2]/@image")
sImageType is string = XMLRead("DOM","/Example/Help[@image=""line.jpg""]/@format", "NotDefined")
XMLClose("DOM")
// Applies to the next XML document:
// <Example>
// <Help>
// <Function type="1">Read</Function>
// <Function>Write</Function>
// </Help>
// <Help image="line.jpg" format="jpg" />
// </Example>
Syntax
<Result> = XMLRead(<XML document> , <Path of element to 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 (with quotes)
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 element to read>: Character string (with quotes)
Can correspond to:
  • the path of the value to read in the XML file. Caution: the case is taken into account (lowercase and uppercase characters). 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 (with quotes)
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.
WINDEV

Code wizard

The code editor proposes a code wizard used 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 : wd250xml.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment