Retrieving Attributes

If desired, you can retrieve element attributes using one of the following C$XML op-codes:

Op-code Description
CXML-GET-ATTRIBUTE-COUNT Gets the number of attributes in an element
CXML-GET-ATTRIBUTE Gets the next attribute
CXML-GET-ATTRIBUTE-BY-NAME     Gets the named attribute

Attributes have special characteristics:

Before you use CXML-GET-ATTRIBUTE, we recommend that you use CXML-GET-ATTRIBUTE-COUNT. This op-code tells you how many attributes are in the element of interest. Then when you use CXML-GET-ATTRIBUTE, you know which attribute you are getting (the first attribute is number 0, the second number 1, etc.).

Alternatively, if you know the name of the attribute you want and not the number of the attribute, you can use CXML-GET-ATTRIBUTE-BY-NAME. If you have an unknown number of attributes like this:

Limousine xmlns:tsd="" xmlns:xsi=""> 

and you are searching for a particular attribute, say "xmlns:xsi", you can search for the value with CXML-GET-ATTRIBUTE-BY-NAME, or you can get the count and read the attributes one by one searching for the one you want.

See General Syntax and Library List for more details on the CXML-GET-ATTRIBUTE op-codes.