CXML-GET-DATA

Retrieves the name and value of an element.

Syntax:

CALL "C$XML" USING CXML-GET-DATA, handle item-name item-value item-value-length

Parameters:

CXML-GET-DATA Op-code 6. Numeric data item that specifies the operation to perform. Each operation is defined in acucobol.def, which is included with your system.
handle USAGE handle
item-name pic x(n)
item-value pic x(n)
item-value-length numeric value

On Entry:

CXML-GET-DATA Value 6
handle Is an element handle or parser handle. If handle is a parser handle, it is first set to the handle of the top-level element of the parsed file.

On Exit:

item-name Is returned as the name of the element.
item-value Is returned as the character data of that element (the data outside of the XML tags).

Comments:

To retrieve data from an element, you use the CXML-GET-DATA op-code. In this operation, you must specify the handle for the element of interest, down to the field level. You can obtain the handle by looking at the return code for the other operations, such as CXML-GET-SIBLING-BY-NAME.

Example:

*Get the handle for the Weather element  
   call "C$XML" using CXML-GET-SIBLING-BY-NAME  
                   ele-1-handle  
                   "weather"  
                   0.  
   move return-code to ele-2-handle.  
*Get the weather data using that handle  
   call "C$XML" using CXML-GET-DATA  
                   ele-2 handle  
                   throw-away-info  
                   weather-val.

Once the XML data is returned, you can then pass it to other parts of your COBOL program for processing or display.