Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The xml-js npm package is a utility that provides methods to convert between XML and JSON format. It can also convert between XML and JavaScript objects. This package is useful when working with XML data in JavaScript environments where JSON is more easily manipulated.
XML to JSON Conversion
Converts an XML string to a JSON string. The options object can be used to customize the output.
const convert = require('xml-js');
const xml = '<note><to>User</to><from>Library</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>';
const options = {compact: true, ignoreComment: true, spaces: 4};
const result = convert.xml2json(xml, options);
console.log(result);
JSON to XML Conversion
Converts a JSON string to an XML string. The options object can be used to customize the output.
const convert = require('xml-js');
const json = '{"note":{"to":"User","from":"Library","heading":"Reminder","body":"Don't forget me this weekend!"}}';
const options = {compact: true, ignoreComment: true, spaces: 4};
const result = convert.json2xml(json, options);
console.log(result);
XML to JavaScript Object
Converts an XML string to a JavaScript object. The options object can be used to customize the output.
const convert = require('xml-js');
const xml = '<note><to>User</to><from>Library</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>';
const result = convert.xml2js(xml, {compact: true, spaces: 4});
console.log(result);
JavaScript Object to XML
Converts a JavaScript object to an XML string. The options object can be used to customize the output.
const convert = require('xml-js');
const jsObject = {
note: {
to: 'User',
from: 'Library',
heading: 'Reminder',
body: 'Don't forget me this weekend!'
}
};
const options = {compact: true, spaces: 4};
const result = convert.js2xml(jsObject, options);
console.log(result);
A very fast XML parser and validator with a similar feature set to xml-js. It can parse XML to a JavaScript object/JSON and vice versa. It is known for its performance and, unlike xml-js, includes XML validation.
Another popular XML to JavaScript converter that provides a similar conversion functionality as xml-js. It includes options to customize the parser behavior and, like xml-js, it does not validate the XML.
This package allows for building XML documents from JavaScript objects, focusing on the creation of XML content. It is more specialized in generating XML and does not provide parsing from XML to JavaScript objects.
Convert XML text to Javascript object (and vice versa) or to JSON text (and vice versa):
Quick start:
<?xml version="1.0" encoding="utf-8"?>
<note importance=”high” logged=”true”>
Watch out!
<time>
11:00 am
</time>
</note>
There are many XML to JavaScript/JSON converters out there, but could not satisfy the following requirements:
npm install --save xml-js
Depending on the size of the project, if it is small and simple enough the reference docs can be added to the README. For medium size to larger projects it is important to at least provide a link to where the API reference docs live.
To perform tests on this project:
cd node_modules/xml-js/test
npm test
Use this link to report an issue or bug. Please include a sample code or Jasmine test spec where the code is failing.
If you want to add a feature or fix a bug, please fork the repository and make the changes in your fork. Add tests to ensure your code is working properly, then submit a pull request.
FAQs
A convertor between XML text and Javascript object / JSON text.
The npm package xml-js receives a total of 1,217,093 weekly downloads. As such, xml-js popularity was classified as popular.
We found that xml-js 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.