Kbase P132546: How to create an XML document in 4GL / ABL using DOM
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  6/9/2009 |
|
Status: Verified
GOAL:
How to create an XML document in 4GL / ABL using DOM
GOAL:
How to create an XML document from a Progress OpenEdge database
GOAL:
Example code using X-DOCUMENT and X-NODEREF object types to create an XML document
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.x
FIX:
The following code illustrates a typical way to use to use ABL support for the Document Object Model (DOM) API to create an XML document from data in an OpenEdge database. It creates an XML document with three main nodes. The first two contain arbitrary text to show how to build any node necessary using ABL statements. The second of the two shows how nodes can be nested in a parent-child relationship. The third main node contains data extracted from the first record in the Customer table of the Sports2000 sample database shipped with OpenEdge.
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hRow AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
CREATE X-DOCUMENT hDoc. /* XML document handle */
CREATE X-NODEREF hRoot. /* root node handle */
CREATE X-NODEREF hRow. /* handle for DB table rows & misc non-DB nodes */
CREATE X-NODEREF hField. /* handle for DB fields & non-DB nested nodes*/
CREATE X-NODEREF hText. /* handle for text nodes */
/*set up a root node*/
hDoc:CREATE-NODE(hRoot,"Datagram","ELEMENT").
hDoc:APPEND-CHILD(hRoot).
hRoot:SET-ATTRIBUTE("xmlns","").
/* For each node below the root: */
/* 1. Create an element node. */
/* 2. Attach it to the root. */
/* 3. Create a text node for it. */
/* 4. Link the text node to the element node. */
/* 5. Fill in the text. */