How to use the xml2js/lib/parser.Parser function in xml2js

To help you get started, we’ve selected a few xml2js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / query-graphs / query-graphs / lib / tableau.js View on Github external
export function loadTableauPlan(graphString, graphCollapse) {
    var result;
    var parser = new XmlParser({
        explicitRoot: false,
        explicitChildren: true,
        preserveChildrenOrder: true,
        // Don't merge attributes. XML attributes will be stored in node["$"]
        mergeAttrs: false
    });
    parser.parseString(graphString, function(err, parsed) {
        if (err) {
            result = {error: "XML parse failed with '" + err + "'."};
        } else {
            var root = prepareTreeData(parsed, graphCollapse);
            var crosslinks = addCrosslinks(root);
            result = {root: root, crosslinks: crosslinks};
        }
    });
    return result;
github tableau / query-graphs / query-graphs / lib / xml.js View on Github external
export function loadXml(graphString, _graphCollapse) {
    var result;
    var parser = new XmlParser({
        explicitRoot: false,
        explicitChildren: true,
        preserveChildrenOrder: true,
        // Don't merge attributes. XML attributes will be stored in node["$"]
        mergeAttrs: false
    });
    parser.parseString(graphString, function(err, parsed) {
        if (err) {
            result = {error: "XML parse failed with '" + err + "'."};
        } else {
            result = {root: convertJSON(parsed)};
        }
    });
    return result;
}