# parseSIMSElement function

StatelessMediaSharingData parseSIMSElement(

1. XMLNode node

)

## Implementation

    StatelessMediaSharingData parseSIMSElement(XMLNode node) {
      assert(node.attributes['xmlns'] == simsXmlns, 'Invalid element xmlns');
      assert(node.tag == 'media-sharing', 'Invalid element name');

      final file = node.firstTag('file', xmlns: jingleFileTransferXmlns)!;
      final hashes = <String, String>{};
      for (final i in file.findTags('hash', xmlns: hashXmlns)) {
        hashes[i.attributes['algo']! as String] = i.innerText();
      }

      var url = '';
      final references =
          file.firstTag('sources')!.findTags('reference', xmlns: referenceXmlns);
      for (final i in references) {
        if (i.attributes['type'] != 'data') continue;

        final uri = i.attributes['uri']! as String;
        if (!uri.startsWith('https://')) continue;

        url = uri;
        break;
      }

      // Thumbnails
      final thumbnails = List<JingleContentThumbnail>.empty(growable: true);
      for (final i
          in file.findTags('thumbnail', xmlns: jingleContentThumbnailXmlns)) {
        thumbnails.add(JingleContentThumbnail.fromXML(i));
      }

      return StatelessMediaSharingData(
        mediaType: file.firstTag('media-type')!.innerText(),
        size: int.parse(file.firstTag('size')!.innerText()),
        description: file.firstTag('description')!.innerText(),
        url: url,
        hashes: hashes,
        thumbnails: thumbnails,
      );
    }