Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 30, 2024 via pnpm

sax 1.2.1

An evented streaming XML parser in JavaScript
Package summary
Share
0
issues
1
license
1
ISC
Package created
9 Feb 2011
Version published
19 Mar 2016
Maintainers
1
Total deps
1
Direct deps
0
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
sax@1.2.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of sax 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does sax do?

Sax is an evented streaming XML parser written in JavaScript. It's designed with Node.js in mind but is also suitable for use in the browser or other CommonJS implementations. It provides a very simple tool for parsing through an XML string and can also serve as a stepping stone towards creating a streaming HTML parser. While it is not an HTML parser, DOM builder, or XML validator, it can prove handy when you are dealing with RSS and other mostly-ok-but-kind-of-broken XML documents.

How do you use sax?

To use it, you first need to require the Sax module. You can then create a new instance of the Sax parser with the strict mode set to either true or false; where setting it to false will enable html-mode. The parser lets you listen for various events such as errors, text, opentags, attributes, and end of parsing. Upon encountering these events, it will call the assigned event listener functions.

Here's a code snippet of how to use the Sax parser in JavaScript:

var sax = require("./lib/sax"),
  strict = true, 
  parser = sax.parser(strict);

parser.onerror = function (e) {
  // an error happened.
};
parser.ontext = function (t) {
  // got some text.  t is the string of text.
};
parser.onopentag = function (node) {
  // opened a tag.  node has "name" and "attributes"
};
parser.onattribute = function (attr) {
  // an attribute.  attr has "name" and "value"
};
parser.onend = function () {
  // parser stream is done, and ready to have more stuff written to it.
};

parser.write('<xml>Hello, <who name="world">world</who>!</xml>').close();

The Sax package also supports stream usage and includes a variety of methods (like write, close, resume) and members (like line, column, position, startTagPosition, closed, strict, etc) which can be used as per the requirement.

Where are the sax docs?

The Sax package documentation can be found in the readme of the GitHub repository. The documentation includes detailed descriptions of the Sax parser's intended use, capabilities along with examples of how to use the module. The readme also comprehensively lists the arguments, methods, members, and events supported by the Sax parser.