mdict-parser.js
function read_header_sect(input, len) {
      var scanner = Scanner(input),
          header_str = scanner.readUTF16(len).replace(/\0$/, ''); // need to remove tailing NUL

      // parse dictionary attributes
      var doc = new DOMParser().parseFromString(header_str,'text/xml');

      var elem = doc.getElementsByTagName('Dictionary')[0];
      if (!elem) {
        elem = doc.getElementsByTagName('Library_Data')[0];
      }

      // console.log(doc.getElementsByTagName('Dictionary')[0].attributes);

      // var xml = parseXml(header_str).querySelector('Dictionary, Library_Data').attributes;

      for (var i = 0, item; i < elem.attributes.length; i++) {
        item = elem.attributes[i];
        attrs[item.nodeName] = item.nodeValue;
      }

      attrs.Encrypted = parseInt(attrs.Encrypted, 10) || 0;

      config();
      return spreadus(len + 4, input);
    }
function read_header_sect(input, len) {
      var scanner = Scanner(input),
          header_str = scanner.readUTF16(len).replace(/\0$/, ''); // need to remove tailing NUL

      // parse dictionary attributes
      var doc = new DOMParser().parseFromString(header_str,'text/xml');

      var elem = doc.getElementsByTagName('Dictionary')[0];
      if (!elem) {
        elem = doc.getElementsByTagName('Library_Data')[0];
      }

      // console.log(doc.getElementsByTagName('Dictionary')[0].attributes);

      // var xml = parseXml(header_str).querySelector('Dictionary, Library_Data').attributes;

      for (var i = 0, item; i < elem.attributes.length; i++) {
        item = elem.attributes[i];
        attrs[item.nodeName] = item.nodeValue;
      }

      attrs.Encrypted = parseInt(attrs.Encrypted, 10) || 0;

      config();
      return spreadus(len + 4, input);
    }
Read header section, parse dictionary attributes and config scanner according to engine version attribute.
@see https://github.com/zhansliu/writemdict/blob/master/fileformat.md#header-section
@param input sliced file (start = 4, length = len + 48), header string + header section (max length 48)
@param len lenghth of header_str
@return [remained length of header section (header_str and checksum, = len + 4), original input]