Progress
External Program
Interfaces


Loading an XML File

The LOAD( ) method reads the specified file into memory, parses it, optionally validates it, and makes its contents available to the 4GL. Once the XML file is in memory, you must get the handle to its root element by using the GET-DOCUMENT-ELEMENT( ) method. Once you have the root node handle, you can manipulate the remaining child nodes.

The following code fragment demonstrates loading an XML file called “myfile.xml”:

DEFINE VARIABLE hDocMine AS HANDLE.
DEFINE VARIABLE hRootMine AS HANDLE.

CREATE X-DOCUMENT hDocMine.
CREATE X-NODEREF hRootMine.

hDocMine:LOAD("FILE","myfile.xml",TRUE).
hDocMine:GET-DOCUMENT-ELEMENT(hRootMine).
. . . 

Loading an XML File From a MEMPTR

An XML file can be read from a MEMPTR as the following code fragment demonstrates:

DEFINE VARIABLE memfile AS MEMPTR.
. . .
FILE-INFO:FILE-NAME = "meminp.xml".
SET-SIZE(memfile) = FILE-INFO:FILE-SIZE.
INPUT FROM "meminp.xml" BINARY NO-CONVERT.
hDoc:LOAD("memptr",memfile,FALSE).
. . . 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095