through stream XML strings into XML nodes matched with CSS3 selectors

npm install selax
8 downloads in the last week
8 downloads in the last month



A module for streaming XML nodes matched with CSS3 selectors using a through stream. Pipe XML data directly out of a file or network connection into Selax and capture the nodes you want with a CSS3 selector pattern.


// Stream temperature nodes from a RSS weather data document (see: )

var source = fs.createReadStream('weatherdata.rss');
var selax = require('selax');

var ax = selax('weatherdata time:first-child temperature');


ax.on('readable', function(){
  var node;

  while(node ={
    console.log('Found matching temperature node: ', node);

ax.on('end', function(){
  console.log('Finished selecting temperature nodes');


Selax is based on libxml2js and emits node objects as plain Javascript objects. Nodes have a type, name, a children array and an attr(name) function for reading attributes.

npm loves you