In french: XMLLit
Returns the value of an XML element or the value of the attribute for an XML element.
MyDoc is string = fLoadText("example.xml")
sFunctionName is string = XMLRead("DOM","/Example/Help/Function")
sFunctionType is string = XMLRead("DOM","Help/Function/@type")
sFunctionName2 is string = XMLRead("DOM","Help/Function")
sImage is string = XMLRead("DOM","Help/@image")
sImageType is string = XMLRead("DOM","/Example/Help[@image=""line.jpg""]/@format", "NotDefined")
// Applies to the next XML document:
// <Function type="1">Read</Function>
// <Help image="line.jpg" format="jpg" />
<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. 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
Text to return if the element was not found. This parameter corresponds to an empty string ("") by default.
- 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.
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
This page is also available for…