You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

saxo-parser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

saxo-parser

A friendly way to configure a SAX parser

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
33
-28.26%
Maintainers
1
Weekly downloads
 
Created
Source

SaxoParser

Purpose

SaxoParser is a helper to configure a sax parser using a self descriptive configuration object.

Installation

npm i -S saxo-parser

Usage

var SaxoParser = require('saxo-parser');

var saxo = new SaxoParser({
	myTag : {
		_open: function(tag) {
			tag.data = {};
			tag.data.someProp = tag.attributes.someProp;
			tag.data.moreProps = [];
		},
		_close: function(tag) {
			// do something with tag.data
			console.log(JSON.stringify(tag.data));
		},
		mySubTag : {
			_close: function(tag) {
				tag.parent.data.moreProps.push(tag.text);
			}
		}
	}
});

saxo.parseString('<root><myTag someProp="someValue"><mySubTag>Some</mySubTag><mySubTag>Text</mySubTag></myTag></root>');

API

The constructor function takes an object describing what function should be called when parsing each xml element.

The entries of the object can be either a tag element name or a special function _open, _text (matches both text and cdata nodes) or _close. None of the special method is mandatory and should be used depending of the object to be parsed.

The parser can then parse a string with parseString, an inputStream with parseStream or a file with parseFile

Keywords

sax

FAQs

Package last updated on 12 Apr 2022

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.