XML_GET_ATTRIBUTE

Script Function: Supplies the value of an element's attribute.

Syntax

XML_GET_ATTRIBUTE (Reference, @Attribute)

Syntax

Description/Format

Reference

The reference to the element whose attribute value should be determined.
Format: script literal or script variable

Attribute

The name of the attribute with a preceding "@".
Format: script literal or script variable


Return codes

The contents of the attribute.
" " - The attribute has no value or the element has no attributes.

Use this script function in order to read an element's attribute value in an XML document. Structured documentation distinguishes between text and listing attribute types, both of which can be read with XML_GET_ATTRIBUTE. There is no limit for the returned value.

Note: You must provide a handle to the script function to access the element. Use a script function that takes position within the XML document to provide the handle. The following are examples of script elements that you can use for this purpose:

Examples

The example shown below retrieves the values of the attributes "Name" (enumeration type) and "Title" (text type). The contents "Smith" and "on call 2012" are written to the activation report.

:SET &XMLDOCU# = XML_OPEN(DOCU,"ON_CALL","@Details")

:  
SET &HND# = XML_GET_FIRST_CHILD(&XMLDOCU#)
:  
SET &HND# = XML_GET_NEXTSIBLING(&HND#)
:  
SET &NAME# = XML_GET_ATTRIBUTE(&HND#, "@Name")
:  
PRINT "attribute value: &NAME#"
:  
SET &TITLE# = XML_GET_ATTRIBUTE(&HND#, "@Title")
:  
PRINT "attribute value: &TITLE#"

:
XML_CLOSE

See also:

seealso

Script Functions for XML Elements