How to use the xml2js.defaults 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 webinos / Webinos-Platform / webinos / core / manager / widget_manager / lib / manifest2policy / manifest2policy.js View on Github external
var manifest2policy = function(manifestFile, appId, features) {
        var manifest = null;

        try {
            var xmlManifest = fs.readFileSync(manifestFile);
            // Load xml parser
            var xmlParser = new xml2js.Parser(xml2js.defaults["0.2"]);
            // Parse manifest
            xmlParser.parseString(xmlManifest, function(err, data) {
                if (err === undefined || err === null) {
                    manifest = data['widget'];
                } else {
                    console.log(err);
                    return '';
                }
            });
        } catch (error) {
            console.log(error);
            return '';
        }

        // target
        var target = [];
github BabylonJS / Extensions / LeaderBoard / Zumo / service / api / blob.js View on Github external
req.get(reqParams, function (e, res, body) {

        if (e || res.statusCode != 200) {
            return callback(body, null);

        }
        var spJs = body;

        var xml2jsSettings = xml2js.defaults['0.2'];
        // these determine what happens if the xml contains attributes
        xml2jsSettings.attrkey = '$';
        xml2jsSettings.charkey = '_';
        // from xml2js guide: always put child nodes in an array if true; otherwise an array is created only if there is more than one.
        xml2jsSettings.explicitArray = false;

        var parser = new xml2js.Parser(xml2jsSettings);
        body = body.toString();
        if (body.charCodeAt(0) === 0xfeff || body.charCodeAt(0) === 0xffef) {
            body = body.substring(1);
        }

        parser.parseString(body, function (err, parsedBody) {
            if (err) {
                return callback(err, null);
            }
github Azure / azure-storage-node / lib / common / services / storageserviceclient.js View on Github external
StorageServiceClient._getDefaultXml2jsSettings = function() {
  var xml2jsSettings = _.clone(xml2js.defaults['0.2']);

  // these determine what happens if the xml contains attributes
  xml2jsSettings.attrkey = Constants.TableConstants.XML_METADATA_MARKER;
  xml2jsSettings.charkey = Constants.TableConstants.XML_VALUE_MARKER;

  // from xml2js guide: always put child nodes in an array if true; otherwise an array is created only if there is more than one.
  xml2jsSettings.explicitArray = false;

  return xml2jsSettings;
};
github webinos / Webinos-Platform / webinos / core / manager / policy_manager / lib / policyeditor.js View on Github external
var policyEditor = function(policy, pmInstance) {
		console.log("Policy editor constructor");
		var pm = pmInstance;
		var policyFile = policy;
		var policySet = null;
		//Load the xml parser
		var xmlParser = new xml2js.Parser(xml2js.defaults["0.2"]);


		this.addRule = function(request, decision) {
			//console.log("\nPolicy Editor - addRule");
			var newTarget = createNewTarget(request);
			var newRule = createNewRule(request, decision);
			loadPolicy(function(){
				insertRule(newTarget, newRule);
				savePolicy();
			});
			//pm.reloadPolicy();
		}


		this.removeRule = function() {
		}
github webinos / Webinos-Platform / webinos / core / manager / synchronisation_manager / index.js View on Github external
this.parseXMLFile= function(fileName, callback) {
        var xml2js = require('xml2js');
        var xmlParser = new xml2js.Parser(xml2js.defaults["0.2"]);
        var data = fs.readFileSync(fileName);
        var result = xmlParser.parseString(data, function(err, xmlData) {
            if(!err) {
                callback(xmlData);
            }
        });
    }
};
github mlegenhausen / node-ogone-directlink / lib / ogone.js View on Github external
},
            pswd: {
                type: 'string',
                required: true
            },
            userid: {
                type: 'string',
                required: true
            }
        }
    }, true);
    var result = JSONSchema.validate(json, schema);
    if (!result.valid) throw new Error(result.errors);
    this.query = Object.clone(json) || {};
    this.url = url;
    this.parser = new xml2js.Parser(xml2js.defaults['0.1']);
}
github webinos / Webinos-Platform / webinos / core / api / mediacontent / lib / mediacontent.js View on Github external
child_process("mediainfo --Output=XML " + directoryPath, function (error, stderr, stdout) {
      if (!error) {
        var xmlParser = new xml2js.Parser(xml2js.defaults["0.2"]);
        xmlParser.parseString(stderr, function(err, xmlData) {
          if(!err){
            callback(id, xmlData);
          }
        });
      }
    });
  }
github Azure / azure-sdk-for-node / lib / services / serviceManagement / models / servicebusparseresponse.js View on Github external
function parseResult(body, contentElementName) {
  if (!body) {
    return;
  }

  var settings = _.clone(xml2js.defaults['0.1']);
  settings.explicitRoot = true;

  var parser = new xml2js.Parser(settings);
  var parsedResult;
  parser.addListener('end', function (result) {
    parsedResult = result;
  });

  parser.parseString(body);

  if (parsedResult.feed) {
    return parseFeedResult(parsedResult.feed, contentElementName);
  }
  if (parsedResult.entry) {
   return parseEntryResult(parsedResult.entry, contentElementName);
  }
github xvrh / localize-with-spreadsheet / node_modules / google-spreadsheet / index.js View on Github external
}, function(err, response, body){
			if (err) {
				return cb( err );
			} else if( response.statusCode === 401 ) {
				return cb( new Error("Invalid authorization key."));
			} else if ( response.statusCode >= 400 ) {
				return cb( new Error("HTTP error " + response.statusCode + ": " + http.STATUS_CODES[response.statusCode]));
			}

			if ( body ){
				var parser = new xml2js.Parser(xml2js.defaults["0.1"]);
				parser.on("end", function(result) {
					cb( null, result, body );
				});

				parser.on("error", function(err) {
					cb( err );
				});

				parser.parseString(body);	
			} else {
				if ( err ) cb( err );
				else cb( null, true );
			}
			
		})
	}
github BabylonJS / Extensions / LeaderBoard / Zumo / service / node_modules / azure / node_modules / azure-common / lib / services / serviceclient.js View on Github external
ServiceClient._getDefaultXml2jsSettings = function() {
  var xml2jsSettings = _.clone(xml2js.defaults['0.2']);
  xml2jsSettings.normalize = false;
  xml2jsSettings.trim = false;
  xml2jsSettings.attrkey = Constants.XML_METADATA_MARKER;
  xml2jsSettings.charkey = Constants.XML_VALUE_MARKER;
  xml2jsSettings.explicitArray = false;

  return xml2jsSettings;
};