> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with Recognized Data

After recognition, an ABBYY FlexiCapture SDK document (the [**Document**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/document.md) object) contains a set of pages with recognized blocks on them and a set of fields. The blocks contain the data received after recognition, while the fields contain the recognized data, to which the rules defined in the Document Definition were applied. For this reason, the content of the blocks may differ from the values of the corresponding fields.

## How to find a field

A collection of document sections (**IDocument::Sections**) usually contains one or several [**Field**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/field.md) objects. However, these are not all of the fields of the document. The fields in this collection are sections of the document. These sections have child fields. Each child field can be either a group of fields (and have its own child fields) or a simple field (without child fields). The document itself can be considered as the topmost-level field which contains all the data fields of the document. To access the child fields of a complex field, use the [**IField::Children**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/field.md#children) property.

A field may have several instances. Field instances are fields that occur several times in the form and describe several variants of the same object, e.g. several telephone numbers or addresses of one person, several table rows of one consignment note, etc. To receive a collection of instance fields, use the [**IField::Instances**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/field.md#instances) property. This collection will contain a set of fields of the same type as the container field.

When working with the recognized data of a document, you must take into account the fact that the document may have a complex tree-like structure, i.e. it may consist of sections, the sections may contain fields and groups of fields, and any of these may re-occur multiple times. Below is a sample of how to go through the entire document tree, visiting every field and every instance of the repeating items. Notice that the collection of instances is checked first to determine if the item is repeating, after that the collection of children is checked to determine if the item is a container of fields:

> [accordion] C# code
>
> ```csharp theme={null}
> // Receive the document's child elements - sections
> FCEngine.IDocument document = null;
> FCEngine.IFields sections = document.Sections;
> // Traverse the tree of document fields
> foreach(FCEngine.IField field in sections)
> {
>     recursiveProcessInstancesAndChildren(field);
> }
>
> void recursiveProcessInstancesAndChildren(FCEngine.IField field)
> {
>     if(field.Instances != null)
>     {
>         foreach(FCEngine.IField fieldInstance in field.Instances)
>         {
>             recursiveProcessInstancesAndChildren(fieldInstance);
>         }
>     }
>     else if(field.Children != null)
>     {
>         foreach(FCEngine.IField child in field.Children)
>         {
>             recursiveProcessInstancesAndChildren(child);
>         }
>     }
> }
> ```

## How to retrieve data from a field

Access to the recognized data of a field is provided by the [**IField::Value**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/field.md#value) property. This property returns a reference to the [**FieldValue**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldvalue.md) object. For composite fields, the property may return NULL. The **FieldValue** object contains recognized data in various formats. The formats in which the data can be presented are defined by the type of these data (**IFieldValue::Type** property). For example, you can receive recognized date and time in DATE format, as a string, or as a **Text** object.

The table below lists the ways of working with the recognized data of a field depending on their type. We presume that the field does not have instance fields (except for the table field).

<table width="100%"><thead><tr><th>**Field type**</th><th>**Children**</th><th>**Field value**</th><th>**How to work with the field**</th></tr></thead><tbody><tr><td>FT\_TextField</td><td>NULL</td><td>Field value of type FVT\_Text</td><td>You can receive the value of the field:<ul><li>as a [**Text**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/text.md) object – use the **IFieldValue::AsText** property</li><li>as a string – use the **IFieldValue::AsString** property</li></ul><details><summary>C++ (COM) code</summary><pre>`// field of type FT_TextField
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Text){
FCEngine::ITextPtr textValue = value->AsText; _bstr_t stringValue = value->AsString;
}`</pre></details></td></tr><tr><td>FT\_DateTimeField</td><td>NULL</td><td>Field value of type FVT\_DateTime</td><td>You can receive the value of the field:<ul><li>as a DATE – use the **IFieldValue::AsDateTime** property</li><li>as a [**Text**](/flexi-capture/sdk/api-reference/text) object – use the **IFieldValue::AsText** property</li><li>as a string – use the **IFieldValue::AsString** property</li></ul><details><summary>C++ (COM) code</summary><pre>`// field of type FT_DateTimeField
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_DateTime){
DATE dateValue = value->AsDateTime; _bstr_t stringValue = value->AsString;
FCEngine::ITextPtr textValue = value->AsText;
}`</pre></details></td></tr><tr><td>FT\_NumberField</td><td>NULL</td><td>Field value of type FVT\_Number</td><td>You can receive the value of the field:<ul><li>as Double – use the **IFieldValue::AsDouble** property</li><li>as Integer – use the **IFieldValue::AsInteger** property</li><li>as a [**Text**](/flexi-capture/sdk/api-reference/text) object – use the **IFieldValue::AsText** property</li><li>as a string – use the **IFieldValue::AsString** property</li></ul><details><summary>C++ (COM) code</summary><pre>`// field of type FT_NumberField
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Number){
double doubleValue = value->AsDouble;
int intValue = value->AsInteger; _bstr_t stringValue = value->AsString;
FCEngine::ITextPtr textValue = value->AsText;
}`</pre></details></td></tr><tr><td>FT\_PictureField</td><td>NULL</td><td>Field value of type FVT\_Picture</td><td>You can receive the value of the field as a [**FieldPictureValue**](/flexi-capture/sdk/api-reference/fieldpicturevalue) object using the **IFieldValue::AsPicture** property.<details><summary>C++ (COM) code</summary><pre>`// field of type FT_PictureField
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Picture){
FCEngine::IFieldPictureValuePtr pictureValue = value->AsPicture;
}`</pre></details></td></tr><tr><td>FT\_Checkmark</td><td>NULL</td><td>Field value of type FVT\_Boolean</td><td>You can receive the value of the field:<ul><li>as Boolean – use the **IFieldValue::AsBoolean** property</li><li>as a string – use the **IFieldValue::AsString** property. The returned string contains localized "Yes" or "No".</li></ul><details><summary>C++ (COM) code</summary><pre>`// field of type FT_Checkmark
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Boolean){
bool boolValue = value->AsBoolean; _bstr_t stringValue = value->AsString;
}`</pre></details></td></tr><tr><td>FT\_CheckmarkGroup</td><td>Fields of the type FT\_Checkmark</td><td>Field value of type FVT\_Choice</td><td>You can receive the value of the field:<ul><li>as a [**FieldChoiceValue**](/flexi-capture/sdk/api-reference/fieldchoicevalue) object – use the **IFieldValue::AsChoice** property. This object contains a collection of available choices and a collection of selected choices. These are collections of type [**FieldValuesCollection**](/flexi-capture/sdk/api-reference/fieldvaluescollection). The collections will contain fields of type FT\_Checkmark. Work with each field as described above.</li><li>as a string – use the **IFieldValue::AsString** property. The returned string contains the value of the selected choice.</li></ul>You can also receive the values of checkmark fields in the group via the child objects of the checkmark group field. Use the **IField::Children** property to receive a collection of child fields of type FT\_Checkmark. Work with each field as described above for this type of field.<details><summary>C++ (COM) code</summary><pre>`// field of type FT_CheckmarkGroup
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Choice){
FCEngine::IFieldChoiceValuePtr choiceValue = value->AsChoice;
// selected choices
FCEngine::IFieldValuesCollectionPtr selectedChoices = choiceValue->SelectedChoices;
for (int i = 0; i < selectedChoices->Count; i++) {
 FCEngine::IFieldValuePtr selectedChoice = selectedChoices->Item(i);
}
// all available choices
FCEngine::IFieldValuesCollectionPtr choices  = choiceValue->Choices;
for (int j = 0; j < choices->Count; j++) {
 FCEngine::IFieldValuePtr choice = choices->Item(j);
} _bstr_t stringValue = value->AsString;
}
// The values of the checkmarks in the group
FCEngine::IFieldsPtr checkmarks = childField->Children;
for (int i = 0; i < checkmarks->Count; i++) {
FCEngine::IFieldPtr checkmark = checkmarks->Item(i);
FCEngine::IFieldValuePtr checkmarkValue = checkmark->Value;
bool checkmarkValueAsBoolean = checkmarkValue->AsBoolean;
}`</pre></details></td></tr><tr><td>FT\_Group</td><td>Fields</td><td>NULL</td><td>Receive the collection of child fields using the **IField::Children** property. Work with each child field depending on its type.</td></tr><tr><td>FT\_PageGroup</td><td>Fields</td><td>NULL</td><td>Receive the collection of child fields using the **IField::Children** property. Work with each child field depending on its type.</td></tr><tr><td>FT\_Table</td><td>NULL or Fields</td><td>NULL</td><td>A table field in ABBYY FlexiCapture SDK contains a collection of instances which correspond to the table rows. Each row field is of type FT\_Table and contains a collection of child fields which correspond to the cells of this row. For each row, the set of field types will be the same. Therefore, you can receive the value of a cell as follows:<ol><li>Receive the collection of instances of the table using the [**IField::Instances**](/flexi-capture/sdk/api-reference/field#instances) property.</li><li>For each field in the collection of instance fields, receive the collection of child fields – use the [**IField::Children**](/flexi-capture/sdk/api-reference/field#children) property.</li><li>Work with each field depending on its type.</li></ol><details><summary>C++ (COM) code</summary><pre>`// field of type FT_Table
FCEngine::IFieldPtr childField;
if (childField->Instances != 0){
FCEngine::IFieldInstancesPtr instances = childField->Instances;
for( int i = 0; i < instances->Count; i++ ) {
 FCEngine::IFieldPtr row = instances->Item(i);
 FCEngine::IFieldsPtr cells = row->Children;
 if( cells != 0){
  for( int j = 0; j < cells->Count; j++){
   FCEngine::IFieldPtr cell = cells->Item(j);
  }
 }
}
}`</pre></details></td></tr><tr><td>FT\_Document</td><td>Fields</td><td>NULL</td><td>Receive the collection of child fields using the **IField::Children** property. Work with each child field depending on its type.</td></tr><tr><td>FT\_CurrencyField</td><td>NULL</td><td>Field value of type FVT\_Currency</td><td>You can receive the value of the field:<ul><li>as a [**Text**](/flexi-capture/sdk/api-reference/text) object – use the **IFieldValue::AsText** property</li><li>as a string – use the **IFieldValue::AsString** property</li></ul><details><summary>C++ (COM) code</summary><pre>`// field of type FT_CurrencyField
FCEngine::IFieldPtr childField;
FCEngine::IFieldValuePtr value = childField->Value;
if (value->Type == FCEngine::FVT_Currency){
FCEngine::ITextPtr textValue = value->AsText; _bstr_t stringValue = value->AsString;
}`</pre></details></td></tr></tbody></table>

## See also

[Verifying Recognized Data](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/verifyingrecognizeddata.md)
