You are here: Function Reference > Alphabetical Listing > S > SrchData

SrchData

Use this function to retrieve data from an XML or flat extract file.

Note The SrchData function, released in version 11.1 and included in version 11.0, patch 32, lets you include spaces in the search criteria, whereas the older GetData function does not. Here is an example:

SrchData("11,HEADERREC,21(A,B, ,D)", 40, 20)

SrchData("'!/XML/Form[@form="PP 03 02"]/@form", 1,10)

Note Note the space between A,B, ,D and PP 03 02.The ability to include spaces in search criteria is important when you are using XML XPaths.

The SrchData function does not format the data it returns.

Note

DAL internally manages Unicode strings using UTF8, which is a standard mechanism for handling Unicode string data. The SrchData function will use this method if the extract file data is defined as XML.

See the Unicode Guide for more information.

Syntax

SrchData (SearchCriteria, Offset, Length, Occurrence)

Parameter

Description

SearchCriteria

Enter the criteria you want the system to use to look for the data in the extract file.

Offset

For XML extract files, enter the offset into the data where the desired data starts.

For flat files, enter the offset into the record where the data starts.

The default is zero (0).

Length

Enter the number of characters to return. The default is zero (0).

Occurrence

This parameter is not valid for XML extract files.

This parameter lets you specify which occurrence of the data to return. Entering one (1) or zero (0) returns the first occurrence of the data.

The default is the first occurrence.

Use this function during Documaker Server processing, after the rule which loads the extract file has been run.

Example

Here are some examples:

In this example, the SrchData function finds the extract record designated by 11,HEADEREC and returns the data at offset 40 for a length of 20:

SrchData ("11,HEADERREC", 40, 20)

This example shows how to use an occurrence variable to get the Nth iteration of the data. In this example, the SrchData function finds the second extract record occurrence designated by search criteria 11,ADDRESS, and returns the data starting at offset 40 for a length of 20.

Entering a one (1) or zero (0) will return the first occurrence of the data.

SrchData ("11,ADDRESS", 40, 17, 2)

Here is an example that gets data from an XML extract file. The SrchData function checks to see if the specified XML extract record equals 2549, if it does, the function returns the string: equal concatenated with the value from another XML extract record. If not, it returns the string: not equal concatenated with a value from a different XML extract record.

value = SrchData ("!Diamond/Data/Client/Accounts/Account/
        Policy/PolicyImages/Policy/premium_fullterm", 1, 7)
If Trim (SrchData ("!Diamond/Data/Client/Accounts/Account/
         Policy/PolicyImages/Policy/premium_fullterm", 1, 4) = "2549" 
  Then
       Return ("equal - " & SrchData ("!/descendant::Personalauto/
           child::Vehicle[**vehovfsym**]/vehicle_num", 1,2)
  Else 
       Return ("not equal - " & value)
End

See also