Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@lezer/xml is a parser for XML syntax built on the Lezer parser system. It provides tools to parse XML documents, create syntax trees, and perform syntax highlighting. This package is useful for applications that need to process or analyze XML data.
Parsing XML
This feature allows you to parse an XML string and generate a syntax tree. The code sample demonstrates how to parse a simple XML string and print the resulting syntax tree.
const {parser} = require('@lezer/xml');
const input = '<root><child>Content</child></root>';
const tree = parser.parse(input);
console.log(tree.toString());
Syntax Highlighting
This feature allows you to perform syntax highlighting on an XML string. The code sample demonstrates how to parse an XML string and apply syntax highlighting using CodeMirror's highlighting utilities.
const {parser} = require('@lezer/xml');
const {highlightTree} = require('@codemirror/highlight');
const {defaultHighlighter} = require('@codemirror/highlight');
const input = '<root><child>Content</child></root>';
const tree = parser.parse(input);
let highlighted = '';
highlightTree(tree, defaultHighlighter, (from, to, classes) => {
highlighted += input.slice(from, to);
highlighted += ` [${classes}]`;
});
console.log(highlighted);
xml2js is a simple XML to JavaScript object converter. It is useful for converting XML data into a more manageable JavaScript object format. Unlike @lezer/xml, which focuses on parsing and syntax trees, xml2js is more about data transformation.
fast-xml-parser is a fast and lightweight XML parser that can convert XML to JSON and vice versa. It is designed for performance and ease of use. Compared to @lezer/xml, fast-xml-parser is more focused on data conversion rather than syntax analysis.
sax is a streaming XML parser for JavaScript. It provides an event-based API for parsing XML documents. While @lezer/xml is more about building syntax trees, sax is useful for applications that need to process XML data in a streaming fashion.
This is an XML grammar for the lezer parser system.
The code is licensed under an MIT license.
FAQs
lezer-based XML grammar
We found that @lezer/xml demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.