# parseDataForm function

DataForm parseDataForm(

1. XMLNode x

)

Parse a Data Form declaration.

## Implementation

    DataForm parseDataForm(XMLNode x) {
      assert(x.attributes['xmlns'] == dataFormsXmlns, 'Invalid element xmlns');
      assert(x.tag == 'x', 'Invalid element name');

      final type = x.attributes['type']! as String;
      final title = x.firstTag('title')?.innerText();
      final instructions =
          x.findTags('instructions').map((i) => i.innerText()).toList();
      final fields = x.findTags('field').map(_parseDataFormField).toList();
      final reported = x
              .firstTag('reported')
              ?.findTags('field')
              .map((i) => _parseDataFormField(i.firstTag('field')!))
              .toList() ??
          [];
      final items = x
          .findTags('item')
          .map((i) => i.findTags('field').map(_parseDataFormField).toList())
          .toList();

      return DataForm(
        type: type,
        instructions: instructions,
        fields: fields,
        reported: reported,
        items: items,
        title: title,
      );
    }