Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Simple wrapper on the SAX.js parser to stream xml into JavaScript objects.
Converts xml elements into JavaScript objects.
npm install xml2object
var xml2object = require('xml2object');
// Create a new xml parser with an array of xml elements to look for
var parser = new xml2object('myAnimals.xml', [ 'animal' ]);
// Bind to the object event to work with the objects found in the XML file
parser.on('object', function(name, obj) {
console.log('Found an object: %s', name);
console.log(obj);
});
// Bind to the file end event to tell when the file is done being streamed
parser.on('end', function(name, obj) {
console.log('Finished parsing xml!');
});
// Start parsing the XML
parser.start();
Constructor for creating an instance of the xml parser
var xml2object = require('xml2object');
// Parse the myAnimals.xml file looking for <animal> elements
var parser = new xml2object('myAnimals.xml', [ 'animal' ]);
Triggers the xml file to start streaming to the parser. Call this method after you have bound to the events.
// Start parsing the XML
parser.start();
function(name, obj) { ... }
Triggered when an object has been parsed from the XML file with the name of the element found and the actual object.
function() { ... }
Marks the end of the input file when it has been completely streamed through the parser.
Elements being parsed cannot currently be nested. For example. if you have root > bikes > bike > wheel
as a heirarchy and have done a xml2object('transportation.xml', [ 'bike', 'wheel' ])
the bike objects will be returned, but the wheel elements inside the bike element will not be parsed separately.
FAQs
Simple XML to JavaScript Object Converter
The npm package xml2object receives a total of 32 weekly downloads. As such, xml2object popularity was classified as not popular.
We found that xml2object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.