0.2.2 • Published 11 years ago

tagstream v0.2.2

Weekly downloads
27
License
-
Repository
github
Last release
11 years ago

tagstream wraps node-expat in a through-stream so you can perform XML parsing as part of a pipeline using event-stream's various fun operators, e.g. map and join, and your own through-streams.

Usage

var es = require('element-stream'),
    tagstream = require('tagstream');

es.pipeline(
  input,
  tagstream(),
  // streams to transform XML events into whatever you want
  output
);

See test/demo.js for one example, which extracts the text from between XML tags.

Each datum carried by the data event out of the tag stream is an array. Depending on the XML event, it'll be one of these:

  • [ 'start', tagName, attributes ]
  • [ 'end', tagName ]
  • [ 'text', text ]

Back-pressure is applied as expected. Due to some event-stream magic, if everything in the pipeline behaves properly then the first input stream will be paused whenever a write fails on the final output stream. That's what I wanted when I started writing this module, so I'm pretty happy.

Testing

npm install to ensure tap is present, then npm test.

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago