Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
js-parse-xml
Advanced tools
Install using NPM or Yarn:
npm i --save js-parse-xml
OR
yarn add js-parse-xml
ESM Imports
import { Parser, parseString, parseStringSync, parseFile, parseFileSync } from "js-parse-xml";
CommonJS Imports
const { Parser, parseString, parseStringSync, parseFile, parseFileSync } = require("js-parse-xml");
Synchronous Parsing
let json = parseStringSync("<xml>Example!</xml>");
// do whatever with the json here
let json = parseFileSync("file.xml");
// do whatever with the json here
Asynchronous Parsing
async function parse(string) {
let json = await parseString(string);
// do whatever with the json here
}
parse("<xml>Testing</xml>");
async function parse(file) {
let json = await parseFile(file, { stream: true });
// do something with the json
}
parse("large_file.xml");
Using the Parser Class
// strict:false will continue parsing if it finds error
let parser = new Parser({ strict: false });
// create stream and feed each chunk to the parser
let stream = fs.createReadStream("filename.xml", "utf-8");
stream.on("data", parser.feed);
stream.on("end", () => {
let json = parser.finish();
// do whatever with the json
});
XML Input
<space:test>
<example>
content
</example>
</space:test>
Parsed JSON Output
{
"test": {
"example": "content"
}
}
XML Input
<test>
<v>0.01e2</v>
<v>0003</v>
<v>-003</v>
<v>0x2f</v>
<v><![CDATA[ <xml> ]]></v>
</test>
Parsed JSON Output
{
"test": {
"v": [1, 3, -3, 47, "<xml>"]
}
}
Configure your parser with available options:
let options = {
encoding: "utf-8",
stream: false,
preserve_whitespace: false,
convert_values: true,
strict: true
};
The goal of this project is to be open source and community-driven. Therefore, contributing is welcomed, and any/all ideas and suggestions are taken into consideration. We welcome everyone to join our Discord server and post questions, comments, concerns, or feature requests! You can also navigate to our Github and open a new issue.
FAQs
lightweight Node-JS xml parser
The npm package js-parse-xml receives a total of 45 weekly downloads. As such, js-parse-xml popularity was classified as not popular.
We found that js-parse-xml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.