How to use the node-expat.createParser function in node-expat

To help you get started, we’ve selected a few node-expat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vchatterji / opml2json / parser.js View on Github external
{	
	//Check if input file exists
	try {
		// Query the entry
		var stats = fs.lstatSync(inputFile);

		// Is it a directory?
		if (stats.isDirectory()) {
			console.log("The specified path:" + inputFile + " is a directory not file.");
		}
		else
		{
			var tree;
			var currentNode;
			
			parser = expat.createParser();
			parser.on('startElement', function (name, attrs) {
				if(name=="outline") {
					if(tree === undefined) {
						tree = {
							parent:null,
							text: attrs.text,
							children: []
						};
						currentNode = tree;
					}
					else {
						var node = {
							parent:currentNode,
							text: attrs.text,
							children: []
						};
github ffalt / xlsx-extract / lib / xlsx-extract.js View on Github external
var getColumnFromDef = function (coldef) {
		var cc = '';
		for (var i = 0; i < coldef.length; i++) {
			if (isNaN(coldef[i])) {
				cc += coldef[i];
			} else {
				break;
			}
		}
		return _utils.alphaNum(cc);
	};

	/*
	 converts cell value according to the cell type & number format
	 */
	var parser = expat.createParser();
	var addvalue = false;
	var row;
	var rownum = 1;
	var cell;
	parser.on('startElement', function (name, attrs) {
		if (name === 'row') {
			if (caller.options.include_empty_rows) {
				var rownr = parseInt(attrs.r, 10);
				//TODO: if rows are not sorted, we are screwed - track and warn user if so
				//reading them first and sort is not wanted, since rows are streamed
				while (rownum < rownr) {
					rownum++;
					cb(null, new Row());
				}
				rownum = rownr + 1;
			}
github ffalt / xlsx-extract / lib / xlsx-extract.js View on Github external
XLSXReader.prototype.parseXMLWorkbook = function (entry, workbook, cb) {
	var parser = expat.createParser();
	parser.on('startElement', function (name, attrs) {
		if (name === 'sheet') {
			var sheet = workbook.validate(attrs['r:id']);
			sheet.id = attrs.sheetId;
			sheet.name = attrs.name;
		}
	});
	parser.on('error', function (err) {
		debug('workbook', err);
	});
	parser.on('close', cb);
	entry.pipe(parser);
};
XLSXReader.prototype.parseXMLWorkbookRelations = function (entry, workbook, cb) {
github ffalt / xlsx-extract / lib / xlsx-extract.js View on Github external
XLSXReader.prototype.parseXMLStrings = function (entry, strings, cb) {
	var parser = expat.createParser();
	var strings_collect = false;
	var sl = [];
	var s = '';
	parser.on('startElement', function (name) {
		if (name === 'si') {
			sl = [];
		}
		if (name === 't') {
			strings_collect = true;
			s = '';
		}
	});
	parser.on('endElement', function (name) {
		if (name === 't') {
			sl.push(s);
			strings_collect = false;

node-expat

NodeJS binding for fast XML parsing.

MIT
Latest version published 10 months ago

Package Health Score

70 / 100
Full package analysis