🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

sax-bastard

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sax-bastard

Easy-peasy XML parsing built on sax-js.

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
5
-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Easy-peasy XML parsing built on sax-js.

sax is too much work for quick XML parsing, and xml2js only works if you never have tags with the same name!

sax-bastard is built on sax-js, but returns a hierarchy of objects, each one having these properties:

  • name (string): the tag name
  • text (string): any text content of the element that is not part of the XML hierarchy
  • attributes (object): the object's properties are the attribute names, the values are the attributes' values
  • children (array): an array containing all of the objects representing any child elements. BUT WAIT THERE'S MORE! The children array/object (HOW CAN IT BE BOTH AT THE SAME TIME JAVASCRIPT IS NUTS) also has a property for each unique tag name among its direct descendants. That property contains an array of all children with that tag.

See the example file for a very slightly more in-depth example!

var parse = require('sax-bastard')
var obj = parse(xml_string, function(err) {
	console.log("This is an error object, because an error happened apparently!")
	console.log(err)
})

If an error happens and no error callback is provided, the parse() function returns the error object instead of the thing you were hoping for.

This module written for ISoft Data Systems, licensed WTFPL.

Keywords

xml

FAQs

Package last updated on 16 Nov 2012

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