Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xml-js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-js - npm Package Compare versions

Comparing version 0.8.9 to 0.9.0

94

lib/xml2js.js

@@ -66,48 +66,2 @@ /*jslint node:true */

module.exports = function(xml, userOptions) {
var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser('UTF-8');
var result = {};
currentElement = result;
options = validateOptions(userOptions);
if (pureJsParser) {
parser.onopentag = onStartElement;
parser.ontext = onText;
parser.oncomment = onComment;
parser.onclosetag = onEndElement;
parser.onerror = onError;
parser.oncdata = onCdata;
parser.onprocessinginstruction = onDeclaration;
} else {
parser.on('startElement', onStartElement);
parser.on('text', onText);
parser.on('comment', onComment);
parser.on('endElement', onEndElement);
parser.on('error', onError);
//parser.on('startCdata', onStartCdata);
//parser.on('endCdata', onEndCdata);
//parser.on('entityDecl', onEntityDecl);
}
if (pureJsParser) {
parser.write(xml).close();
} else {
if (!parser.parse(xml)) {
throw new Error('XML parsing error: ' + parser.getError());
}
}
if (result[options.elementsKey]) {
var temp = result[options.elementsKey];
delete result[options.elementsKey];
result[options.elementsKey] = temp;
delete result.text;
}
return result;
};
function onDeclaration (declaration) {

@@ -243,2 +197,48 @@ if (options.ignoreDeclaration) {

console.error('error', error);
}
}
module.exports = function(xml, userOptions) {
var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser('UTF-8');
var result = {};
currentElement = result;
options = validateOptions(userOptions);
if (pureJsParser) {
parser.onopentag = onStartElement;
parser.ontext = onText;
parser.oncomment = onComment;
parser.onclosetag = onEndElement;
parser.onerror = onError;
parser.oncdata = onCdata;
parser.onprocessinginstruction = onDeclaration;
} else {
parser.on('startElement', onStartElement);
parser.on('text', onText);
parser.on('comment', onComment);
parser.on('endElement', onEndElement);
parser.on('error', onError);
//parser.on('startCdata', onStartCdata);
//parser.on('endCdata', onEndCdata);
//parser.on('entityDecl', onEntityDecl);
}
if (pureJsParser) {
parser.write(xml).close();
} else {
if (!parser.parse(xml)) {
throw new Error('XML parsing error: ' + parser.getError());
}
}
if (result[options.elementsKey]) {
var temp = result[options.elementsKey];
delete result[options.elementsKey];
result[options.elementsKey] = temp;
delete result.text;
}
return result;
};
{
"name": "xml-js",
"version": "0.8.9",
"version": "0.9.0",
"description": "A convertor between XML text and Javascript object / JSON text.",

@@ -59,3 +59,2 @@ "main": "index.js",

"rimraf": "^2.5.2",
"watchify": "latest",
"watch": "^0.18.0"

@@ -62,0 +61,0 @@ },

@@ -17,3 +17,3 @@ ![XML ⇔ JS/JSON](http://nashwaan.github.io/xml-js/images/logo.svg)

[![Dependency Status](https://david-dm.org/nashwaan/xml-js.svg)](https://david-dm.org/nashwaan/xml-js)
[![Package Quality](http://xxxnpm.packagequality.com/shield/xml-js.svg)](http://packagequality.com/#?package=xml-js)
[![Package Quality](http://xxxnpm.packagequality.com/shield/xml-js.svg)](http://xxxpackagequality.com/#?package=xml-js)

@@ -20,0 +20,0 @@ # Synopsis

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc