Socket
Socket
Sign inDemoInstall

saxes

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

saxes

An evented streaming XML parser in JavaScript


Version published
Weekly downloads
21M
decreased by-2.12%
Maintainers
1
Weekly downloads
 
Created

What is saxes?

The saxes npm package is a highly efficient XML parser designed for modern JavaScript environments. It is a pure JavaScript library that supports XML Namespaces and is optimized for speed and low memory usage. Saxes is particularly useful for parsing large XML files and streams, making it ideal for server-side applications where performance is critical.

What are saxes's main functionalities?

Parsing XML Strings

This code demonstrates how to use saxes to parse a simple XML string. It sets up event handlers for opening tags, text content, and closing tags, then processes an XML string.

const SaxesParser = require('saxes').SaxesParser;
const parser = new SaxesParser();
parser.on('opentag', node => {
  console.log(`Opened tag: ${node.name}`);
});
parser.on('text', text => {
  console.log(`Text content: ${text}`);
});
parser.on('closetag', name => {
  console.log(`Closed tag: ${name}`);
});
parser.write('<root>Hello <child>World</child></root>').close();

Error Handling

This example shows how to handle errors in XML parsing with saxes. The parser attempts to process malformed XML, triggering an error event that logs the error message.

const SaxesParser = require('saxes').SaxesParser;
const parser = new SaxesParser();
parser.on('error', error => {
  console.error('Parsing error:', error.message);
});
parser.write('<root><unclosedTag></root>').close();

Other packages similar to saxes

FAQs

Package last updated on 07 Nov 2021

Did you know?

Socket

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.

Install

Related posts

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