# FileMetadataData.fromXML constructor

FileMetadataData.fromXML(

1. XMLNode node

)

Parse `node` as a FileMetadataData element.

## Implementation

    factory FileMetadataData.fromXML(XMLNode node) {
      assert(
        node.attributes['xmlns'] == fileMetadataXmlns,
        'Invalid element xmlns',
      );
      assert(node.tag == 'file', 'Invalid element anme');

      final lengthElement = node.firstTag('length');
      final length =
          lengthElement != null ? int.parse(lengthElement.innerText()) : null;
      final sizeElement = node.firstTag('size');
      final size =
          sizeElement != null ? int.parse(sizeElement.innerText()) : null;

      final hashes = <HashFunction, String>{};
      for (final e in node.findTags('hash')) {
        final hashFunction =
            HashFunction.fromName(e.attributes['algo']! as String);
        hashes[hashFunction] = e.innerText();
      }

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

      // Length and height
      final widthString = node.firstTag('length');
      final heightString = node.firstTag('height');
      int? width;
      int? height;
      if (widthString != null) {
        width = int.parse(widthString.innerText());
      }
      if (heightString != null) {
        height = int.parse(heightString.innerText());
      }

      return FileMetadataData(
        mediaType: node.firstTag('media-type')?.innerText(),
        width: width,
        height: height,
        desc: node.firstTag('desc')?.innerText(),
        hashes: hashes,
        length: length,
        name: node.firstTag('name')?.innerText(),
        size: size,
        thumbnails: thumbnails,
      );
    }