CXML-ADD-ATTRIBUTE

Syntax:

CALL "C$XML" USING CXML-ADD-ATTRIBUTE, handle, attr-name, attr-value, attr-value-len

Parameters:

CXML-ADD-ATTRIBUTE Op-code 29. 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
attr-name Literal or pic x(n)
attr-data

Optional

Literal or pic x(n)
attr-len

(Optional)

Numeric literal or pic x(n)

On Entry:

CXML-ADD-ATTRIBUTE Value 29
handle An element handle.
attr-value The new attribute value, of length attr-value-len (if given) or the length of the data element given as the attr-name.
attr-value-len (Optional) The length of the new attribute value.

On Exit:

RETURN-CODE The index of the new attribute, or “0” on error.

Example:

working-storage section.
01 parser-handle usage is handle.
01 element-handle usage is handle.
COPY "acucobol.def".
procedure division.
main-logic.  
*Create a new XML file 
   call "C$XML" using CXML-NEW-PARSER
   move return-code to parser-handle.  
 
*Add a top element (using the name of the file)
   call "C$XML" using CXML-ADD-CHILD 
                  parser-handle
                  "custRec" 
   move return-code to element-handle.  
 
*Add some namespace information  
   call "C$XML" using CXML-ADD-ATTRIBUTE
                  element-handle
                  "xmlns:xsi" 
                  "http://www.w3.org/2001/XMLSchema-instance".