lib/utils/xml-utils.js
function parse(xml) {
    var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();
    var doc;
    try {
        doc = parser.parseFromString(xml, 'application/xml');
    } catch (e) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);
    }
    if (!doc.documentElement) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');
    }
    var parserError = doc.getElementsByTagName('parsererror')[0];
    if (parserError) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);
    }
    return doc;
}
function parse(xml) {
    var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();
    var doc;
    try {
        doc = parser.parseFromString(xml, 'application/xml');
    } catch (e) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);
    }
    if (!doc.documentElement) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');
    }
    var parserError = doc.getElementsByTagName('parsererror')[0];
    if (parserError) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);
    }
    return doc;
}
function parse ( xml ) { var parser = domParserArg ? new dom . DOMParser ( domParserArg ) : new dom . DOMParser ( ) ; var doc ; try { doc = parser . parseFromString ( xml , 'application/xml' ) ; } catch ( e ) { throw new KdbxError ( Consts . ErrorCodes . FileCorrupt , 'bad xml: ' + e . message ) ; } if ( ! doc . documentElement ) { throw new KdbxError ( Consts . ErrorCodes . FileCorrupt , 'bad xml' ) ; } var parserError = doc . getElementsByTagName ( 'parsererror' ) [ 0 ] ; if ( parserError ) { throw new KdbxError ( Consts . ErrorCodes . FileCorrupt , 'bad xml: ' + parserError . textContent ) ; } return doc ; }
Parses XML document
Throws an error in case of invalid XML
@param {string} xml - xml document
@returns {Document}
Parses XML document Throws an error in case of invalid XML