code: function parseSvg (svg) {
    if (typeof svg !== 'string') {
      throw new TypeError('Failed to parse non-string target: ' + JSON.stringify(svg));
    }
  
    var doc = new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement;
  
    if (doc === null || doc === undefined || doc.getElementsByTagName('parsererror').length !== 0) {
      throw new ParseError('Invalid SVG and/or XML', { src: svg, result: doc });
    } else if (!/svg/i.test(doc.tagName)) {
      throw new MainError('Parsed XML is not SVG', { src: svg, result: doc });
    } else {
      return doc;
    }
  }
docs: Some Utilities: