Automation Engine Script Guide > Ordered by Function > Read or Modify Objects > XML_GET_ATTRIBUTE

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.

Comments

Use this script function in order to read an element's attribute value in an XML document.

It requires a reference to be able to access the element. This reference is provided by script elements that can be positioned within the XML document (such as XML_GET_FIRST_CHILD, XML_GET_NEXTSIBLING, XML_SELECT_NODE, or XML_OPEN).

Structured documentation distinguishes the attribute types "text" and "listing", both of which may be read using XML_GET_ATTRIBUTE.

There is no limit for the returned value.

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 protocol.

: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

 

Also see:

Script Elements - Read or Modify Objects

Structured Documentation

www.w3c.org/TR/xmlbase

About Scripts
Script Elements - Alphabetical Listing

Script-Elements - Ordered by Function