XML FIND FILE

This statement has the following parameters:

Parameter Description
DirectoryName A nonnumeric literal or an identifier of an alphanumeric data item, the value of which is the name of the directory to search for files.
FileName An identifier of an alphanumeric data item that will contain the name of a found file upon successful completion of the statement.
[ExtensionName] Optional. A nonnumeric literal or an identifier of an alphanumeric data item, the value of which is the extension having the format .aaa. The leading dot is required, but the extension is not limited in length other than reasonable file name length limits. When omitted, the default extension name is .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