How to use the xml2js/lib/processors.parseNumbers 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
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'
    },
    xmldec: {
github DefinitelyTyped / DefinitelyTyped / xml2js / xml2js-tests.ts View on Github external
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'
    },
    xmldec: {
github nordnet / cordova-hot-code-push / scripts / lib / xmlHelper.js View on Github external
function readXmlAsJson(filePath, simplify) {
  var xmlData;
  var parsedData;
  var parserOptions = {};

  if (simplify) {
    parserOptions = {
      attrValueProcessors: [xml2jsProcessors.parseNumbers, xml2jsProcessors.parseBooleans],
      explicitArray: false,
      mergeAttrs: true,
      explicitRoot: false
    };
  }

  var xmlParser = new xml2js.Parser(parserOptions);
  try {
    xmlData = fs.readFileSync(filePath);
    xmlParser.parseString(xmlData, function(err, data) {
      if (data) {
        parsedData = data;
      }
    });
  } catch (err) {}