mediaext.js
function parseXMP (data) {
    return new Promise(function(resolve, reject) {
        var parserstrict = true;
        var parser = sax.parser(parserstrict);

        var nodepath = [];
        var currentnode = null;
        var outdata = {};

        parser.onerror = function (err) { reject({error:MediaExt.ERROR.PARSEXML, internalerror:err}) };
        parser.onopentag = function (node) {
            nodepath.push(node.name);
            if(node.attributes) {
                for(var att in node.attributes) {
                    if(!node.attributes.hasOwnProperty(att))
                        continue;

                    var value = node.attributes[att];
                    nodepath.push(att);
                    setOutdata(nodepath, value, outdata);
                    nodepath.pop();
                }
            }
            currentnode = node;
        }
        parser.onclosetag = function (node) {
            nodepath.pop();
            currentnode = null;
        }
        parser.ontext = function (value) {
            setOutdata(nodepath, value, outdata);
        }
        parser.onend = function (data) { resolve(outdata) };
        parser.write(data).close();
    });
}
function parseXMP (data) {
    return new Promise(function(resolve, reject) {
        var parserstrict = true;
        var parser = sax.parser(parserstrict);

        var nodepath = [];
        var currentnode = null;
        var outdata = {};

        parser.onerror = function (err) { reject({error:MediaExt.ERROR.PARSEXML, internalerror:err}) };
        parser.onopentag = function (node) {
            nodepath.push(node.name);
            if(node.attributes) {
                for(var att in node.attributes) {
                    if(!node.attributes.hasOwnProperty(att))
                        continue;

                    var value = node.attributes[att];
                    nodepath.push(att);
                    setOutdata(nodepath, value, outdata);
                    nodepath.pop();
                }
            }
            currentnode = node;
        }
        parser.onclosetag = function (node) {
            nodepath.pop();
            currentnode = null;
        }
        parser.ontext = function (value) {
            setOutdata(nodepath, value, outdata);
        }
        parser.onend = function (data) { resolve(outdata) };
        parser.write(data).close();
    });
}
PRIVATE