node package manager

saxtojson

sax2json

Epic sax guy

About

Tree-like list of commands parser. Every command has a name. It can also have an attributes and children.

Installation

npm install saxtojson

Usage

var s2j = require('saxtojson');
var parser = Object.create(s2j.Parser).init();

var command = parser.parseFile('path/to/file.sax');

// `command` is now a root command without name and arguments
// but it should have some children
console.log(command.childrenJSON());

For input file:

click "a[name=b]" 
	equal "title" "foo"
	ok 2 > 1

it will print JSON representation:

[[
	"click", "a[name=b]", [[
		"equal",
		"title",
		"foo"
	], [
		"ok":
		"2",
		">",
		"1"
	]]
]]

Tests Build Status

npm test