XML FIND FILE

This statement has the following parameters:

Parameter Description
DirectoryName The name of the directory to check for XML documents (files ending with the .xml extension).
FileName The name of one XML document (file ending with the .xml extension) that was found in the specified directory.
Extension A user-specified extension having the format, .aaa. Unless Extension is specified, the statement looks only for files in the directory that have an extension of ".xml".

Description

The XML FIND FILE statement looks in the directory specified by the DirectoryName parameter for an XML document (a file with the .xml extension, unless the Extension parameter is specified). If there are one or more XML documents in the specified directory, the name of one of the files will be returned in the FileName parameter.

If the statement succeeds (the condition XML-IsSuccess is true), the XML document specified by the FileName parameter may be processed by using XML IMPORT FILE.

Before calling XML FIND FILE again (to process the next file), you must call XML REMOVE FILE to delete the XML document that was just processed. Otherwise, the next call to the XML FIND FILE statement may return the same file.

A status value is returned in the XML-data-group data item, which is defined in the copybook, lixmldef.cpy. The condition XML-IsDirectoryEmpty will be true if the directory is empty.

Example

FIND-DOCUMENT.
    PERFORM WITH TEST AFTER UNTIL 0 > 1
        XML FIND FILE
            "MY-DIRECTORY"
            MY-FILE-NAME
        IF XML-IsSuccess
            EXIT PERFORM
        END-IF
        IF XML-IsDirectoryEmpty
            CALL "C$DELAY" USING 0.1
        END-IF
        IF NOT XML-OK GO TO Z.
    END-PERFORM
*> Process found document