ADELIA |
VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) |
(I/B) (C/S) |
(B) (S) |
(I/B) (C/S) |
(I) (C/S) |
Section for use
All.
Syntax
XML_GET_VAL XmlIdentifierName <result variable>
or
XML_GET_VAL XmlIdentifierName SeriesVarAttribute
SeriesVarAttribute |
Þ |
SeriesVarAttribute, VarAttribute | VarAttribute |
VarAttribute |
Þ |
AttributeId <result variable> |
VarAttribute |
Þ |
AttributeId <result variable> |
Description
Returns the values of the attributes specified for the current node in the result variables.
You can use the *TEXT directive to retrieve the value of the node's text. This directive can be omitted if only the text associated with the node is to be retrieved.
The result variable's type depends on the type in which you want to retrieve the value.
*NAME retrieves the local node's name, in which case the result variable will always be alphanumerical.
*PREFNS retrieves the prefix of the node. In this case, the result variable will always be alphanumerical. *PREFNS returns a *BLANK value if the node has not been prefixed.
Note: If an XML file is read sequentially (i.e. when the XML identifier was declared with the *SEQ option), *NAME returns special values when certain node types are read.
Comment node |
Returns the value: #comment |
Text or blank node |
Returns the value: #text |
CDATA node |
Returns the value: #cdata-section |
Node end node |
Returns the value: /node_name |
When this instruction is executed, the *RETURN_CODE reserved word can take the following values:
0 (*NORMAL) |
Operation completed successfully. |
10 |
One or more of the requested attributes or text does not exist for the current node. The variable is initialized with the default value for its type. The instruction is executed in the normal way for the other attributes. |
13 |
Error: XML identifier not open. |
-1 |
Error: type conversion problem involving the retrieved value and the specified variable for one or more text attributes. |
27 |
Namespace URI not found. |
Example
* To retrieve the current node's text
XML_GET_VAL xml1 WTEXT
* To retrieve the current node's attributes and text
XML_GET_VAL xml1 Attribute1 Var1, Attribute2 Var2, *TEXT Var3
* Attributes (whose names are stored in variables) and text of the current node are retrieved
ALPHA(15) AttrName1
ALPHA(15) AttrName2
AttrName1 = 'Attribute1'
AttrName1 = 'Attribute2'
XML_GET_VAL xml1 &AttrName1 Var1, &AttrName2 Var2, *TEXT Var3
* To retrieve the prefixed attributes
XML_ADD_NS xml1 'zz' 'urn:xmlns:25hoursaday-com:bookstore'
...
XML_GET_VAL xml1 zz:Attribute1 Var1, zz:Attribute2 Var2
* To retrieve the prefix of the current node
XML_GET_VAL xml1 *PREFNS PrefVar