Open tmcw opened 2 years ago
Here are a few lines useful to achieve this:
if (data.indexOf("<") != 0) {
throw 'Invalid XML';
}
let xml = (new DOMParser()).parseFromString(data, "text/xml");
let type = xml.documentElement.tagName.toLowerCase(); // "kml" or "gpx"
if (xml.getElementsByTagName('parsererror').length) {
throw 'Invalid XML';
}
Source: leaflet-elevation/src/control.js#L956-L975
👋 Raruto
Options:
kml
tag, if it is not found, return an error.