How to use the xml2js/lib/processors.normalize 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 DefinitelyTyped / DefinitelyTyped / types / xml2js / xml2js-tests.ts View on Github external
explicitChildren: false,
    childkey: '$$',
    preserveChildrenOrder: false,
    charsAsChildren: false,
    includeWhiteChars: false,
    async: false,
    strict: true,
    attrNameProcessors: undefined,
    attrValueProcessors: undefined,
    tagNameProcessors: undefined,
    valueProcessors: undefined
}, (err: Error, result: any) => { });

xml2js.parseString('Hello xml2js!', {
    attrNameProcessors: [processors.firstCharLowerCase, xml2js.processors.normalize],
    attrValueProcessors: [processors.normalize],
    tagNameProcessors: [processors.stripPrefix],
    valueProcessors: [processors.parseBooleans, processors.parseNumbers]
}, (err: Error, result: any) => { });

let builder = new xml2js.Builder({
    renderOpts: {
        pretty: false
    }
});

builder = new xml2js.Builder({
    rootName: 'root',
    renderOpts: {
        pretty: true,
        indent: ' ',
        newline: '\n'
github DefinitelyTyped / DefinitelyTyped / xml2js / xml2js-tests.ts View on Github external
explicitChildren: false,
    childkey: '$$',
    preserveChildrenOrder: false,
    charsAsChildren: false,
    includeWhiteChars: false,
    async: false,
    strict: true,
    attrNameProcessors: undefined,
    attrValueProcessors: undefined,
    tagNameProcessors: undefined,
    valueProcessors: undefined
}, (err: any, result: any) => { });

xml2js.parseString('Hello xml2js!', {
    attrNameProcessors: [processors.firstCharLowerCase],
    attrValueProcessors: [processors.normalize],
    tagNameProcessors: [processors.stripPrefix],
    valueProcessors: [processors.parseBooleans, processors.parseNumbers]
}, (err: any, result: any) => { });

var builder = new xml2js.Builder({
    renderOpts: {
        pretty: false
    }
});

var builder = new xml2js.Builder({
    rootName: 'root',
    renderOpts: {
        pretty: true,
        indent: ' ',
        newline: '\n'
github communitybridge / easycla / src / node_modules / passport-cas / index.js View on Github external
} else {
        this.client = https;
    }

    passport.Strategy.call(this);


    this.name = 'cas';
    this._verify = verify;
    this._passReqToCallback = options.passReqToCallback;

    var xmlParseOpts = {
        'trim': true,
        'normalize': true,
        'explicitArray': false,
        'tagNameProcessors': [processors.normalize, processors.stripPrefix]
    };

    var self = this;
    switch (this.version) {
        case "CAS1.0":
            this._validateUri = "/validate";
            this._validate = function (req, body, verified) {
                var lines = body.split('\n');
                if (lines.length >= 1) {
                    if (lines[0] === 'no') {
                        return verified(new Error('Authentication failed'));
                    } else if (lines[0] === 'yes' && lines.length >= 2) {
                        if (self._passReqToCallback) {
                            self._verify(req, lines[1], verified);
                        } else {
                            self._verify(lines[1], verified);
github kylepixel / cas-authentication / index.js View on Github external
this._validate = function(body, callback) {
            parseXML(body, {
                trim: true,
                normalize: true,
                explicitArray: false,
                tagNameProcessors: [ XMLprocessors.normalize, XMLprocessors.stripPrefix ]
            }, function(err, result) {
                if (err) {
                    return callback(new Error('Response from CAS server was bad.'));
                }
                try {
                    var samlResponse = result.envelope.body.response;
                    var success = samlResponse.status.statuscode.$.Value.split(':')[ 1 ];
                    if (success !== 'Success') {
                        return callback(new Error('CAS authentication failed (' + success + ').'));
                    }
                    else {
                        var attributes = {};
                        var attributesArray = samlResponse.assertion.attributestatement.attribute;
                        if (!(attributesArray instanceof Array)) {
                            attributesArray = [ attributesArray ];
                        }